Stuck on Copying DocumentObject or ComplexGeoData

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
wandererfan
Veteran
Posts: 6307
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Stuck on Copying DocumentObject or ComplexGeoData

Post by wandererfan »

I'm working on this: issue #3329 (Object placement in exported Stl). I fixed a similar situation in TechDraw by making copies of TopoShapes, applying globalPosition(), and exporting the copies.

But I'm having trouble getting something I can modify. I need to make a copy of the DocumentObject or the ComplexGeoData, but I get "use of deleted function" (no explicit copy constructor?).

Code: Select all

bool MergeExporter::addPartFeat(App::DocumentObject *obj, float tol)
{
    auto *shape(obj->getPropertyByName("Shape"));
//    App::DocumentObject objCopy(*obj);         <<< these would be good 
//    App::DocumentObject* objCopy = obj->Copy(); <<<

    if (shape && shape->getTypeId().isDerivedFrom(App::PropertyComplexGeoData::getClassTypeId())) {
        Base::Reference<MeshObject> mesh(new MeshObject());

        auto countFacets( mergingMesh.countFacets() );

       //  geoData is const :(
        auto geoData( static_cast<App::PropertyComplexGeoData*>(shape)->getComplexData() ); 
//        auto gd2(geoData->Copy());                  <<<  want something like this ( !const)
        if (geoData) {
            App::GeoFeature* gf = static_cast<App::GeoFeature*>(obj);
            // setPlacement breaks const :(   -  but I shouldn't modify the original anyway
//            geoData->setPlacement(gf->globalPlacement()); 

            std::vector<Base::Vector3d> aPoints;
            std::vector<Data::ComplexGeoData::Facet> aTopo;
            geoData->getFaces(aPoints, aTopo, tol);
            ...
I could make this work by using Part::Feature and/or Part::TopoShape, but that would make Mesh module need the *h file(s) from Part and the OCC include lib, and I'm guessing that would be discouraged(?).

Any advice?
Post Reply