MeshKit  1.0
AF2FreeZoneDefSimple.cpp
Go to the documentation of this file.
00001 #include "meshkit/AF2FreeZoneDefSimple.hpp"
00002 #include "meshkit/Error.hpp"
00003 
00004 AF2FreeZoneDefSimple::AF2FreeZoneDefSimple(
00005         std::list<AF2Point2D> const & rfrncBndryPnts,
00006         std::list<const AF2PointTransform*> const & bndryPntTrnsfrms)
00007 {
00008   // confirm that the lists are the same size
00009   if (rfrncBndryPnts.size() != bndryPntTrnsfrms.size())
00010   {
00011     MeshKit::Error badArg(MeshKit::MK_BAD_INPUT);
00012     badArg.set_string("The lists of reference points and point transforms are not the same size");
00013     throw badArg;
00014   }
00015 
00016   numPoints = rfrncBndryPnts.size();
00017   bndryPoints = new AF2Point2D[numPoints];
00018   pointTransforms = new const AF2PointTransform*[numPoints];
00019   int pIndx = 0;
00020   for (std::list<AF2Point2D>::const_iterator itr =
00021       rfrncBndryPnts.begin(); itr != rfrncBndryPnts.end(); ++itr)
00022   {
00023     bndryPoints[pIndx] = *itr;
00024     ++pIndx;
00025   }
00026 
00027   pIndx = 0;
00028   for (std::list<const AF2PointTransform*>::const_iterator itr =
00029       bndryPntTrnsfrms.begin(); itr != bndryPntTrnsfrms.end(); ++itr)
00030   {
00031     pointTransforms[pIndx] = (*itr)->clone();
00032     ++pIndx;
00033   }
00034 }
00035 
00036 AF2FreeZoneDefSimple::~AF2FreeZoneDefSimple()
00037 {
00038   delete[] bndryPoints;
00039   for (int pIndx = 0; pIndx < numPoints; ++pIndx)
00040   {
00041     delete pointTransforms[pIndx];
00042   }
00043   delete[] pointTransforms;
00044 }
00045 
00046 AF2FreeZoneDefSimple::AF2FreeZoneDefSimple(const AF2FreeZoneDefSimple & toCopy)
00047 {
00048   numPoints = toCopy.numPoints;
00049   bndryPoints = new AF2Point2D[numPoints];
00050   pointTransforms = new const AF2PointTransform*[numPoints];
00051   for (int pIndx = 0; pIndx < numPoints; ++pIndx)
00052   {
00053     bndryPoints[pIndx] = toCopy.bndryPoints[pIndx];
00054     pointTransforms[pIndx] = toCopy.pointTransforms[pIndx]->clone();
00055   }
00056 }
00057 
00058 AF2FreeZoneDefSimple& AF2FreeZoneDefSimple::operator=(
00059     const AF2FreeZoneDefSimple & rhs)
00060 {
00061   // copy constructor functionality,
00062   // but to other parts of memory, not yet to this
00063   AF2Point2D* otherBndryPoints = new AF2Point2D[numPoints];
00064   const AF2PointTransform** otherPointTransforms =
00065       new const AF2PointTransform*[numPoints];
00066   for (int pIndx = 0; pIndx < numPoints; ++pIndx)
00067   {
00068     otherBndryPoints[pIndx] = rhs.bndryPoints[pIndx];
00069     otherPointTransforms[pIndx] = rhs.pointTransforms[pIndx]->clone();
00070   }
00071 
00072   // destructor functionality
00073   delete[] bndryPoints;
00074   for (int pIndx = 0; pIndx < numPoints; ++pIndx)
00075   {
00076     delete pointTransforms[pIndx];
00077   }
00078   delete[] pointTransforms;
00079 
00080   // transfer ownership from other parts of memory to this object
00081   numPoints = rhs.numPoints;
00082   bndryPoints = otherBndryPoints;
00083   otherBndryPoints = NULL; // not necessary, but to be explicit
00084   pointTransforms = otherPointTransforms;
00085   otherPointTransforms = NULL; // not necessary, but to be explicit
00086 
00087   // return this
00088   return *this;
00089 }
00090 
00091 AF2FreeZoneDefSimple* AF2FreeZoneDefSimple::clone() const
00092 {
00093   return new AF2FreeZoneDefSimple(*this);
00094 }
00095 
00096 AF2FreeZone* AF2FreeZoneDefSimple::makeFreeZone(
00097     AF2Binding const & vertexBinding, unsigned int qualityClass) const
00098 {
00099   std::list<AF2Point2D> freeZoneBndry;
00100   for (int pIndx = 0; pIndx < numPoints; ++pIndx)
00101   {
00102     freeZoneBndry.push_back(pointTransforms[pIndx]->transformPoint(
00103         bndryPoints[pIndx], vertexBinding));
00104   }
00105   AF2FreeZone* freeZone = new AF2FreeZone(freeZoneBndry);
00106   return freeZone;
00107 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines