Same problem: ConstructUnion doesn't work.I'm developing with ArcGIs Engine SDK 10.1 for C++/Qt and I'm on Linux.Here is my code:
IGeometryBagPtr cGeometryBag(CLSID_GeometryBag);
IGeometryCollectionPtr cGeometryCollection = cGeometryBag; // QI
IGeometryPtr * cGeomVector = new IGeometryPtr[len];
for (i = 0; i < len; i++)
{
IPointCollectionPtr cPointCollection(CLSID_Polygon);
// I fill the cPointCollection object with my polygones (triangles)
IPolygonPtr cPolygon = cPointCollection; // QI
cGeomVector = cPolygon;
}
hr = cGeometryCollection -> AddGeometries((long)len, (IGeometry**)cGeomVector);
if (FAILED(hr))
{
cout << "Impossible to add geometries" << std::endl;
return;
}
long cGeomCount;
hr = cGeometryCollection -> get_GeometryCount(&cGeomCount);
if (FAILED(hr))
{
cout << "Impossible to calculate the number of geometries (1)" << std::endl;
return;
}
cout << "Number of geometries (1): " << cGeomCount << std::endl;
// in this dump I see that the number of geometries (in the GeometryCollection) is OK
IEnumGeometryPtr cEnumGeometry = cGeometryBag; // QI
hr = cEnumGeometry -> get_Count(&cGeomCount);
if (FAILED(hr))
{
cout << "Impossible to calculate the number of geometries (2)" << std::endl;
return;
}
cout << "Number of geometries (2): " << cGeomCount << std::endl;
// in this dump I see that the number of geometries (in the EnumGeometry) is OK
IPolygonPtr cResultPolygon(CLSID_Polygon);
ITopologicalOperator2Ptr cTopoOp = cResultPolygon;
hr = cTopoOp -> ConstructUnion(cEnumGeometry);
if (FAILED(hr))
{
cout << "Impossible to do ConstructUnion" << std::endl;
return;
}
IPointCollectionPtr cFinalPointCollection = cResultPolygon; // QI
hr = cFinalPointCollection -> get_PointCount(&cGeomCount);
if (FAILED(hr))
{
cout << "Impossible to calculate the number of points (3)" << std::endl;
return;
}
cout << "Number of points (3): " << cGeomCount << std::endl;
// In this dump the number (of points of the new geometry) is not OK, is always zero!
Where do I go wrong?Are there examples in C++ to refer to?The result remains the same (negative) if I change the line:IPointCollectionPtr cFinalPointCollection = cResultPolygon; // QI
with:IPointCollectionPtr cFinalPointCollection = cTopoOp; // QI
Any help would be appreciated.Cheers from Italy.