У меня есть класс с именем Test, который наследует класс TopoDS_Face.Уже получил несколько советов от Этот вопрос , но ...
// Test.h
class Test : public TopoDS_Face
{
public:
void operator = (const TopoDS_Face& base_)
{
TopoDS_Face::operator=(base_);
}
}
// testmain.cpp
...
int main() {
//extract faces from IGES face
for (int i = 1; i <= nbs; i++) {
TopoDS_Shape shape = myIgesReader.Shape(i);
TopoDS_Face& face = static_cast<TopoDS_Face&>(TopoDS::Face(shape));
Test *test;
// tried each of these also and did not succeed
// Test *test = dynamic_cast<Test*>(&face);
// test = &face
test->TopoDS_Face::operator=(face);
...
}
}
Код в main извлекает грани из файла IGES и назначает каждый объект грани тестовому объекту, созданному в main.Компиляция идет хорошо, но valgrind жалуется на следующую ошибку:
==21718== Use of uninitialised value of size 8
==21718== at 0x9B0946C: Handle_Standard_Transient::Assign(Standard_Transient const*) (in /usr/lib64/libTKernel.so.10.0.0)
==21718== by 0x408111: Handle_TopoDS_TShape::operator=(Handle_TopoDS_TShape const&) (in /home/ub/Projects/C++/test/test)
==21718== by 0x409478: TopoDS_Shape::operator=(TopoDS_Shape const&) (in /home/ub/Projects/C++/test/test)
==21718== by 0x4094CA: TopoDS_Face::operator=(TopoDS_Face const&) (in /home/ub/Projects/C++/test/test)
==21718== by 0x407273: main (in /home/ub/Projects/C++/test/test)
==21718==
==21718== Use of uninitialised value of size 8
==21718== at 0x9B09431: Handle_Standard_Transient::EndScope() (in /usr/lib64/libTKernel.so.10.0.0)
==21718== by 0x9B09475: Handle_Standard_Transient::Assign(Standard_Transient const*) (in /usr/lib64/libTKernel.so.10.0.0)
==21718== by 0x408111: Handle_TopoDS_TShape::operator=(Handle_TopoDS_TShape const&) (in /home/ub/Projects/C++/test/test)
==21718== by 0x409478: TopoDS_Shape::operator=(TopoDS_Shape const&) (in /home/ub/Projects/C++/test/test)
==21718== by 0x4094CA: TopoDS_Face::operator=(TopoDS_Face const&) (in /home/ub/Projects/C++/test/test)
==21718== by 0x407273: main (in /home/ub/Projects/C++/test/test)
==21718==
==21718== Invalid read of size 4
==21718== at 0x9B0943C: Handle_Standard_Transient::EndScope() (in /usr/lib64/libTKernel.so.10.0.0)
==21718== by 0x9B09475: Handle_Standard_Transient::Assign(Standard_Transient const*) (in /usr/lib64/libTKernel.so.10.0.0)
==21718== by 0x408111: Handle_TopoDS_TShape::operator=(Handle_TopoDS_TShape const&) (in /home/ub/Projects/C++/test/test)
==21718== by 0x409478: TopoDS_Shape::operator=(TopoDS_Shape const&) (in /home/ub/Projects/C++/test/test)
==21718== by 0x4094CA: TopoDS_Face::operator=(TopoDS_Face const&) (in /home/ub/Projects/C++/test/test)
==21718== by 0x407273: main (in /home/ub/Projects/C++/test/test)
==21718== Address 0x75eb394801c38350 is not stack'd, malloc'd or (recently) free'd
==21718==
==21718==
==21718== Process terminating with default action of signal 11 (SIGSEGV)
==21718== General Protection Fault
==21718== at 0x9B0943C: Handle_Standard_Transient::EndScope() (in /usr/lib64/libTKernel.so.10.0.0)
==21718== by 0x9B09475: Handle_Standard_Transient::Assign(Standard_Transient const*) (in /usr/lib64/libTKernel.so.10.0.0)
==21718== by 0x408111: Handle_TopoDS_TShape::operator=(Handle_TopoDS_TShape const&) (in /home/ub/Projects/C++/test/test)
==21718== by 0x409478: TopoDS_Shape::operator=(TopoDS_Shape const&) (in /home/ub/Projects/C++/test/test)
==21718== by 0x4094CA: TopoDS_Face::operator=(TopoDS_Face const&) (in /home/ub/Projects/C++/test/test)
==21718== by 0x407273: main (in /home/ub/Projects/C++/test/test)
==21718==
Мне нужна помощь в решении программы.Заранее спасибо.