int OCCFace::offset(double offset, double tolerance = 1e-6) { try { BRepOffset_MakeOffset MO(this->getShape(), offset, tolerance, BRepOffset_Skin, Standard_False, Standard_False, GeomAbs_Intersection, Standard_False); if (!MO.IsDone()) { StdFail_NotDone::Raise("Failed to offset face"); } const TopoDS_Shape& tmp = MO.Shape(); BRepCheck_Analyzer aChecker(tmp); if (tmp.IsNull() || !aChecker.IsValid()) { StdFail_NotDone::Raise("offset result not valid"); } this->setShape(tmp); // possible fix shape if (!this->fixShape()) StdFail_NotDone::Raise("Shapes not valid"); } catch(Standard_Failure &err) { Handle_Standard_Failure e = Standard_Failure::Caught(); const Standard_CString msg = e->GetMessageString(); if (msg != NULL && strlen(msg) > 1) { setErrorMessage(msg); } else { setErrorMessage("Failed to offset face"); } return 0; } return 1; }
void STLStorageTest::PoolStorageTest() { StartTrace(STLStorageTest.PoolStorageTest); // create a vector, using MyAlloc<> as allocator PoolAllocator pa(1, 1024, 12); pa.PrintStatistic(3L); MemChecker aChecker("STLStorageTest.PoolStorageTest", coast::storage::Global()); { stlstorage::STLAllocator<int> stlalloc(&pa); std::vector<int, stlstorage::STLAllocator<int> > v(stlalloc); // insert elements // - causes reallocations pa.PrintStatistic(3L); v.push_back(42); v.push_back(56); v.push_back(11); v.push_back(22); v.push_back(33); v.push_back(44); pa.PrintStatistic(3L); } assertComparem(0LL, equal_to, aChecker.CheckDelta(), "expected no unfreed memory"); pa.PrintStatistic(3L); { stlstorage::STLAllocator<int> stlalloc(&pa); std::list<int, stlstorage::STLAllocator<int> > v(stlalloc); // insert elements // - causes reallocations pa.PrintStatistic(3L); v.push_back(42); v.push_back(56); v.push_back(11); v.push_back(22); v.push_back(33); v.push_back(44); pa.PrintStatistic(3L); } assertComparem(0LL, equal_to, aChecker.CheckDelta(), "expected no unfreed memory"); pa.PrintStatistic(3L); { stlstorage::STLAllocator<int> stlalloc(&pa); std::deque<int, stlstorage::STLAllocator<int> > v(stlalloc); // insert elements // - causes reallocations pa.PrintStatistic(3L); v.push_back(42); v.push_back(56); v.push_back(11); v.push_back(22); v.push_back(33); v.push_back(44); pa.PrintStatistic(3L); } assertComparem(0LL, equal_to, aChecker.CheckDelta(), "expected no unfreed memory"); pa.PrintStatistic(3L); }
void STLStorageTest::GlobalStorageTest() { StartTrace(STLStorageTest.GlobalStorageTest); // create a vector, using STLAllocator<> as allocator using coast::storage::Global() MemChecker aChecker("STLStorageTest.GlobalStorageTest", coast::storage::Global()); { std::vector<int, stlstorage::STLAllocator<int> > v; // insert elements // - causes reallocations v.push_back(42); v.push_back(56); v.push_back(11); v.push_back(22); v.push_back(33); v.push_back(44); } assertComparem(0LL, equal_to, aChecker.CheckDelta(), "expected no unfreed memory"); aChecker.TraceDelta("mem change after test"); }
void STLStorageTest::AllocatorUsingSMartPtrTest() { StartTrace(STLStorageTest.AllocatorUsingSMartPtrTest); typedef something listType; // typedef Teststorage::pool_allocator<listType, stlstorage::BoostPoolUserAllocatorCurrent> blaType; // typedef stlstorage::pool_allocator<listType, stlstorage::BoostPoolUserAllocatorGlobal> blaType; typedef stlstorage::fast_pool_allocator<listType, itostorage::BoostPoolUserAllocatorGlobal> blaType; MemChecker aChecker("STLStorageTest.AllocatorUsingSMartPtrTest", coast::storage::Current()); { blaType pool1; } assertComparem(0LL, equal_to, aChecker.CheckDelta(), "expected no unfreed memory"); Trace("========================== deque tests 1 =========================="); { std::deque<listType, blaType > v; // insert elements listType elt1 = { 1, 1 }; Trace("adding element"); v.push_back(elt1); } assertComparem(0LL, equal_to, aChecker.CheckDelta(), "expected no unfreed memory"); Trace("========================== list test 1 =========================="); { std::list<listType, blaType > v; // insert elements listType elt1 = { 1, 1 }; Trace("adding element"); v.push_back(elt1); } assertComparem(0LL, equal_to, aChecker.CheckDelta(), "expected no unfreed memory"); Trace("========================== list test 3 =========================="); { std::list<listType, blaType > v; // insert elements listType elt1 = { 1, 1 }; listType elt2 = { 1, 2 }; listType elt3 = { 3, 1 }; Trace("adding element"); v.push_back(elt1); Trace("adding element"); v.push_back(elt2); Trace("adding element"); v.push_back(elt3); } assertComparem(0LL, equal_to, aChecker.CheckDelta(), "expected no unfreed memory"); Trace("========================== vector tests =========================="); { std::vector<listType, blaType > v; // insert elements listType elt1 = { 1, 1 }; listType elt2 = { 1, 2 }; listType elt3 = { 3, 1 }; Trace("adding element"); v.push_back(elt1); Trace("adding element"); v.push_back(elt2); Trace("adding element"); v.push_back(elt3); } assertComparem(0LL, equal_to, aChecker.CheckDelta(), "expected no unfreed memory"); Trace("========================== deque tests 2 =========================="); { std::deque<listType, blaType > v; // insert elements listType elt1 = { 1, 1 }; listType elt2 = { 1, 2 }; Trace("adding element"); v.push_back(elt1); Trace("adding element"); v.push_back(elt2); } assertComparem(0LL, equal_to, aChecker.CheckDelta(), "expected no unfreed memory"); Trace("========================== deque tests 3 =========================="); { std::deque<listType, blaType > v; // insert elements listType elt1 = { 1, 1 }; listType elt2 = { 1, 2 }; listType elt3 = { 3, 1 }; Trace("adding element"); v.push_back(elt1); Trace("adding element"); v.push_back(elt2); Trace("adding element"); v.push_back(elt3); } assertComparem(0LL, equal_to, aChecker.CheckDelta(), "expected no unfreed memory"); Trace("========================== two deque tests 3 =========================="); { std::deque<listType, blaType > v, w; // insert elements listType elt1 = { 1, 1 }; listType elt2 = { 1, 2 }; listType elt3 = { 3, 1 }; Trace("adding element"); v.push_back(elt1); w.push_back(elt1); Trace("adding element"); v.push_back(elt2); w.push_back(elt2); Trace("deleting element"); v.pop_front(); w.pop_front(); Trace("adding element"); v.push_back(elt3); w.push_back(elt3); } assertComparem(0LL, equal_to, aChecker.CheckDelta(), "expected no unfreed memory"); Trace("========================== two list tests 3 =========================="); { std::list<listType, blaType > v, w; // insert elements listType elt1 = { 1, 1 }; listType elt2 = { 1, 2 }; listType elt3 = { 3, 1 }; Trace("adding element"); v.push_back(elt1); w.push_back(elt1); Trace("adding element"); v.push_back(elt2); w.push_back(elt2); Trace("deleting element"); v.pop_front(); w.pop_front(); Trace("adding element"); v.push_back(elt3); w.push_back(elt3); } assertComparem(0LL, equal_to, aChecker.CheckDelta(), "expected no unfreed memory"); }