how does solome do this ???

Please look at my previous post about offsetting a solid. The same geometry works perfectly in Salome but I can't get it to work using BRepOffset_MakeOffset. How do they do this ????

Thanks in advance,

Jouke

Mark Blome's picture

Hi Jouke,

that's interesting. Taking a quick look at GEOMImpl_OffsetDriver.cpp the difference seems to be that they perform a ShapeFix_ShapeTolerance on the resulting shape if required.
Here are the corresponding lines of code:
BRepOffsetAPI_MakeOffsetShape MO (aShapeBase,
aCI.GetValue(),
aTol);
if (MO.IsDone()) {
aShape = MO.Shape();
// 23.04.2010 skl for bug 21699 from Mantis
BRepCheck_Analyzer ana (aShape, Standard_True);
ana.Init(aShape);
if (!ana.IsValid()) {
ShapeFix_ShapeTolerance aSFT;
aSFT.LimitTolerance(aShape, Precision::Confusion(),
Precision::Confusion(), TopAbs_SHAPE);
Handle(ShapeFix_Shape) aSfs = new ShapeFix_Shape(aShape);
aSfs->Perform();
aShape = aSfs->Shape();
ana.Init(aShape);
if (!ana.IsValid())
Standard_ConstructionError::Raise("Boolean operation aborted : non valid shape result");
}
}

Or maybe the difference is that Salome uses BRepOffsetAPI_MakeOffsetShape instead of the BRepOffset_MakeOffset you use ?
Good luck with your offset issue,
Mark

hylkema's picture

Hi Mark,

Thanks a lot for your answer. I Implemented the changes but no success :-( This is driving me mad ...

Jouke

hylkema's picture

This is what I do:

for (int i = 1;i<20;i++) {
Kernel = offset(0.1,Kernel);
}

with :

TopoDS_Shape Model2::offset(double dist,TopoDS_Shape original) {

double res = Precision::Confusion();
BRepOffsetAPI_MakeOffsetShape mkOffset(original,dist,res);
TopoDS_Shape tmp;
if (mkOffset.IsDone()) {
tmp = mkOffset.Shape();
} else {
StdFail_NotDone::Raise("Offset construction failed");
}

return Fix(tmp);
}

and :

TopoDS_Shape Model2::Fix(TopoDS_Shape shape){
BRepCheck_Analyzer ana (shape, Standard_True);
ana.Init(shape);
if (!ana.IsValid()) {
cout<<"Fixing the shape"<<"\n";
ShapeFix_ShapeTolerance aSFT;
aSFT.LimitTolerance(shape, Precision::Confusion(),Precision::Confusion(), TopAbs_SHAPE);
Handle(ShapeFix_Shape) aSfs = new ShapeFix_Shape(shape);
aSfs->Perform();
shape = aSfs->Shape();
ana.Init(shape);
if (!ana.IsValid()) {
Standard_ConstructionError::Raise("Boolean operation aborted : non valid shape result");
}
}
return shape;
}

It goes OK for the first 4 and then it crashes ...

Mark Blome's picture

Hi Jouke,

Which version of Salome did you use for your tests ? And which version of Opencascade do you compile your program with ?

Regards,
Mark

hylkema's picture

Goodmorning Mark,

Salome: 6.5.0
OCC:6.5.0 (installed from the ubuntu repositories, not compiled my self)

Mark Blome's picture

Hi Jouke,

maybe there is a difference in the way how Salome reads in your STEP file compared to the method you use with OCC ?
If you can get the job done using Salome, why not use Salome through it's python interface or the standalone GEOM library available at http://sourceforge.net/projects/salomegeometry/ in your project ?

Good luck,
Mark

hylkema's picture

Mark,

That might be the problem. However the rest of my project is in C++ so mixing this with pyton might not be easy but I give it a try.

Thanks,

Jouke

hylkema's picture

It's strange though. The error is :

Error making offset :BRepOffset_MakeOffset : Tol > Offset

however :
Offset = 0.1
Tol = 1e-06

Go figure :-(

hylkema's picture

Hi Mark,

I'm afraid I need more help. Have you tried to install the python interface ? It complains at compilation and I realy don't get what is bugging it ...

make[1]: Entering directory `/Software/GEOM/6.3.1.8/adm/lin'
/bin/bash ./libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I/usr/local/inc -I./inc/ -I./src/GEOMAlgo -I./src/BlockFix -I./src/GEOM -I./src/NMTTools -I./src/NMTDS -I./src/Exchange3DS -D_OCC64 -g -O2 -MT NMTDS_CArray1OfIndexRange_0.lo -MD -MP -MF .deps/NMTDS_CArray1OfIndexRange_0.Tpo -c -o NMTDS_CArray1OfIndexRange_0.lo `test -f './src/NMTDS/NMTDS_CArray1OfIndexRange_0.cpp' || echo './'`./src/NMTDS/NMTDS_CArray1OfIndexRange_0.cpp
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I/usr/local/inc -I./inc/ -I./src/GEOMAlgo -I./src/BlockFix -I./src/GEOM -I./src/NMTTools -I./src/NMTDS -I./src/Exchange3DS -D_OCC64 -g -O2 -MT NMTDS_CArray1OfIndexRange_0.lo -MD -MP -MF .deps/NMTDS_CArray1OfIndexRange_0.Tpo -c ./src/NMTDS/NMTDS_CArray1OfIndexRange_0.cpp -fPIC -DPIC -o .libs/NMTDS_CArray1OfIndexRange_0.o
In file included from ./src/NMTDS/NMTDS_CArray1OfIndexRange_0.cpp:39:0:
/usr/local/inc/BOPTColStd_CArray1.gxx:243:32: error: no 'void NMTDS_CArray1OfIndexRange::Purge()' member function declared in class 'NMTDS_CArray1OfIndexRange'
make[1]: *** [NMTDS_CArray1OfIndexRange_0.lo] Error 1
make[1]: Leaving directory `/Software/GEOM/6.3.1.8/adm/lin'
make: *** [all] Error 2

Mark Blome's picture

Hi Jouke,

looking at your post I assume you are trying to compile the latest version of the standalone GEOM module found on sourceforge, right ?
The compile error looks like as if you are compiling the geom module with the wrong version of the Opencascade library.
Not sure which version of OCC (my guess: 6.3.0) this GEOM module relies on, but I guess it's not the one you are working with for your project (6.5.0 ?).

My guess is you would need to switch to OCC 6.3.0 for your project in order to integrate the GEOM module. Note that once you have compiled everything you can of course use the GEOM classes directly in your c++ project, i.e. there's no need to mix python and c++.

Regards,
Mark