int main() { Rectangle aSquare(3, 3); Rectangle aRectangle(2, 3); Circle aCircle(10); Parallelepiped aPrism(2.3, 2.3, 2.3); Cube aCube(2); std::cout << aSquare.surface() << std::endl; std::cout << aRectangle.perimeter() << std::endl; std::cout << aCircle.surface() << std::endl; std::cout << aPrism.surface() << std::endl; std::cout << aPrism.volume() << std::endl; std::cout << aCube.surface() << std::endl; std::cout << aCube.volume() << std::endl; return 0; }
/** * Modifies a label for a file containing a subarea. The AlphaCube, Mapping, * and Instrument groups are all affected when a subarea is extracted from * another file. If the linc is not equal to the sinc, then the Instrument * and Mapping groups will be removed from the label because they will no * longer be valid. If the linc is equal to the sinc and they are not equal * to 1, then the map scale and resolution in the Mapping group needs to be * updated. The latitude and longitude ranges become invalid when the subarea * does not cover the entire sample and line range of the original cube. * Update the upper left corner x,y values if the projection is still valid * and the starting line and/or starting sample have been changed from their * location in the original file. * * @param icube This is the input cube that will have the subarea * extracted from it. The label of this cube will be used to * create updated Mapping, Instrument, and AlphaCube groups * for the label of the output cube containing the subarea. * * @param ocube This is the output cube file containing the subarea. The * label of this cube will be modified by extracting the Mapping, * Instrument, and AlphaCube groups from the input label and * putting them in this label. * * @param results This is the Results group that will go into the application * log file. This group must be created by the calling application. * Information will be added to it if the Mapping or Instrument * groups are deleted from the output image label. * */ void SubArea::UpdateLabel(Cube *icube, Cube *ocube, PvlGroup &results) { Pvl inlabel = *icube->label(); // If the linc and sinc are not equal, then the Instrument and // Mapping groups are no longer valid. if(p_linc != p_sinc) { if(inlabel.findObject("IsisCube").hasGroup("Mapping")) { inlabel.findObject("IsisCube").deleteGroup("Mapping"); results += PvlKeyword("MappingGroupDeleted", "True"); // We don't want to think our projected cube is unprojected, so if we // delete a mapping group and we have a camera there is a problem. // Remove the camera. if(inlabel.findObject("IsisCube").hasGroup("Instrument")) { inlabel.findObject("IsisCube").deleteGroup("Instrument"); results += PvlKeyword("InstrumentGroupDeleted", "True"); } } } if(inlabel.findObject("IsisCube").hasGroup("Mapping")) { // Update the upper left corner X,Y values if the starting line or // starting sample are changed. if(p_sl != 1 || p_ss != 1) { Projection &proj = *icube->projection(); proj.SetWorld(p_ss - 0.5, p_sl - 0.5); PvlGroup &mapgroup = inlabel.findObject("IsisCube").findGroup("Mapping", Pvl::Traverse); mapgroup.addKeyword(PvlKeyword("UpperLeftCornerX", toString(proj.XCoord())), Pvl::Replace); mapgroup.addKeyword(PvlKeyword("UpperLeftCornerY", toString(proj.YCoord())), Pvl::Replace); } // If the linc and sinc are not equal to 1, then update the // mapping scale and resolution. if(p_linc == p_sinc && p_linc != 1.0) { PvlGroup &mapgroup = inlabel.findObject("IsisCube").findGroup("Mapping", Pvl::Traverse); QString pixresUnit = mapgroup["PixelResolution"].unit(); double pixres = toDouble(mapgroup["PixelResolution"][0]); mapgroup["PixelResolution"] = toString(pixres * p_linc); mapgroup["PixelResolution"].setUnits(pixresUnit); QString scaleUnit = mapgroup["Scale"].unit(); double scale = mapgroup["Scale"]; mapgroup["Scale"] = toString(scale / p_linc); mapgroup["Scale"].setUnits(scaleUnit); } // If the outer bounds of the image are changed, then the // latitude,longitude range is no longer valid. if(p_sl != 1 || p_ss != 1 || p_el != p_nl || p_es != p_ns) { PvlGroup &mapgroup = inlabel.findObject("IsisCube").findGroup("Mapping", Pvl::Traverse); if(mapgroup.hasKeyword("MinimumLatitude")) { mapgroup.deleteKeyword("MinimumLatitude"); } if(mapgroup.hasKeyword("MaximumLatitude")) { mapgroup.deleteKeyword("MaximumLatitude"); } if(mapgroup.hasKeyword("MinimumLongitude")) { mapgroup.deleteKeyword("MinimumLongitude"); } if(mapgroup.hasKeyword("MaximumLongitude")) { mapgroup.deleteKeyword("MaximumLongitude"); } } } // Make changes to the output cube label if(ocube->hasGroup("Instrument")) { ocube->deleteGroup("Instrument"); } if(inlabel.findObject("IsisCube").hasGroup("Instrument")) { PvlGroup inst; inst = inlabel.findObject("IsisCube").findGroup("Instrument"); ocube->putGroup(inst); } if(ocube->hasGroup("Mapping")) { ocube->deleteGroup("Mapping"); } if(inlabel.findObject("IsisCube").hasGroup("Mapping")) { PvlGroup mapgrp; mapgrp = inlabel.findObject("IsisCube").findGroup("Mapping"); ocube->putGroup(mapgrp); } // Update the AlphaCube group - this group will only be updated if // a Mapping group does not exist in the labels. AlphaCube aCube(p_ns, p_nl, ocube->sampleCount(), ocube->lineCount(), p_ss - 0.5, p_sl - 0.5, p_es + 0.5, p_el + 0.5); aCube.UpdateGroup(*ocube->label()); }