Example #1
0
bool LinearPropagator::propagate_true(const LinearConstraint& l)
{
    assert(l.getRelation()==LinearConstraint::Relation::LE);
    auto minmax = computeMinMax(l);
    if (minmax.second <= l.getRhs())
        return true;

    for (auto i : l.getViews())
    {
        auto r = vs_.getCurrentRestrictor(i);
        auto wholeRange = vs_.getRestrictor(i); 
        std::pair<int64,int64> mm;
        mm.first = minmax.first - r.lower();
        mm.second = minmax.second - r.upper();

            int64 up = l.getRhs() - mm.first;
            if (up < r.lower())
            {
                //std::cout << "Constrain Variable " << i.first << " with new upper bound " << up << std::endl;
                return false;
            }
            if (up < r.upper())
            {
                //std::cout << "Constrain Variable " << i.first << " with new upper bound " << up << std::endl;
                //auto newUpper = std::lower_bound(wholeRange.begin(), wholeRange.end(), up);
                auto newUpper = std::upper_bound(wholeRange.begin(), wholeRange.end(), up);
                if (!constrainUpperBound(newUpper)) // +1 is needed, as it is in iterator pointing after the element
                    return false;
                minmax.first = mm.first + r.lower();
                minmax.second = mm.second + *(newUpper-1);
            }
    }
    return true;
}
Example #2
0
void ObjectWalkmesh::load(const Common::UString &resRef, float orientation[4], float position[3]) {
	WalkmeshLoader loader;
	std::vector<uint32> faceProperties;
	loader.load(Aurora::kFileTypePWK, resRef, orientation, position,
	            _vertices, _faces, faceProperties);

	computeMinMax();
}
Example #3
0
bool LinearPropagator::propagate_impl(ReifiedLinearConstraint &rl)
{
    const LinearConstraint& l = rl.l;
    assert(l.getRelation()==LinearConstraint::Relation::LE);
    auto minmax = computeMinMax(l);

    if (minmax.first>l.getRhs())
        return s_.createClause(LitVec{~rl.v});

    return true;
}
Example #4
0
void VisusMeshDisplay::renderColoredSmooth()
{
  std::vector<VisusMeshData::IndexDataType>::iterator it;

  pVisusSharedColorMap colorMap = sharedValue<VisusSharedColorMap>();
  if (colorMap->lockToRead() == 0) {
    vwarning("Could not lock color map for reading. Rendering aborted.");
    return;
  }

  glShadeModel(GL_SMOOTH);
  //fprintf(stderr,"VisusMeshDisplay::renderColoredSmooth()\n");
  // Find Min / Max for color map if not hand-set
  if (mMinValue > mMaxValue) 
    computeMinMax();
  mValueRange = mMaxValue - mMinValue;
  
  // Get Local Colormap
  switch (mMesh.elementDim()) {
  case 3:
    glBegin(GL_TRIANGLES);
    break;
  case 4:
    glBegin(GL_QUADS);
    break;
  default:
    glBegin(GL_POLYGON);
    break;
  }

  // Loop and Draw
  for (uint32_t i=0;i<mMesh.nrOfElements();i++) 
  {
	std::vector<VisusMeshData::IndexDataType>& element = mMesh.element(i);
        
    // Draw Values
    for (it=element.begin();it!=element.end();it++) 
    { 
      VisusMeshData::IndexDataType idx = *it;
      //glTexCoord1f(mMesh.vertex(idx)[mColorIndex]);
      setColor(*colorMap, mMesh.vertex(idx)[mColorIndex]);
      glNormal3fv(mMesh.componentAddress(idx,mNormalIndex));
      glVertex3fv(mMesh.vertexAddress(idx));
    }
  }

  glEnd();

  if (colorMap->unlockAfterRead() == 0) {
    vwarning("Could not unlock color map after renderin. Aborting rendring.");
    return;
  }
  
}
Example #5
0
std::vector<LinearLiteralPropagator::LinearConstraintClause> LinearLiteralPropagator::propagate_impl(ReifiedLinearConstraint& rl)
{
    std::vector<LinearLiteralPropagator::LinearConstraintClause> ret;
    const LinearConstraint& l = rl.l;
    assert(l.getRelation()==LinearConstraint::Relation::LE);

    LinearConstraintClause::itervec clause;
    auto minmax = computeMinMax(l, clause);
    if (minmax.first>l.getRhs())
    {
        //clause.emplace_back(~rl.v);
        LinearConstraintClause c(rl);
        c.setClause(clause);
        ret.emplace_back(std::move(c));
    }
    return ret;
}
Example #6
0
        bool redraw(bool bClear = true)
            {
                double minX,maxX,minY,maxY;
                double zeroX,zeroY;
                double lineWidth;
                if (!computeMinMax(minX,maxX,minY,maxY))
                {
                    cerr << "Could not compute the minmax" << endl;
                    return false;
                }
//            lineWidth = 2.0*Utils::min(double(maxX-minX)/width(),double(maxY-minY)/height());
                lineWidth = 1.0;

                zeroX = (-double(minX)*(width()-1.0)/(maxX-minX));
                zeroY = (-double(minY)*(height()-1.0)/(maxY-minY));

                int basis;
                basis=createBasis(zeroX,zeroY,(width()-1.0)/double(maxX-minX),(height()-1.0)/double(maxY-minY));
                for (int i=0;i<mFunctions.size();i++)
                {
                    Functions *f = &mFunctions[i];
                    Surface *surface = new Surface(*f->pFunction,f->minX,f->minY,f->maxX-f->minX,f->maxY-f->minY);
                    addDrawable(basis,surface,false);
                }
                for (int i=0;i<mLines.size();i++)
                {
                    for (int j=1;j<mLines[i].xs.size();j++)
                    {
                        Line *line = new Line(mLines[i].xs[j-1],mLines[i].ys[j-1],mLines[i].xs[j],mLines[i].ys[j],lineWidth);
                        addDrawable(basis,line,false);
                    }
                }
                for (int i=0;i<mRectangles.size();i++)
                {
//                 Rectangle *rect = new Rectangle(mRectangles[i].x,mRectangles[i].y,mRectangles[i].w,mRectangles[i].h,lineWidth,mRectangles[i].color);
//                 addDrawable(basis,rect,false);
                }
                if (bClear)
                    clear();
                flip();
                return true;
            }
vector<Data> DataSet::scale(vector<Data> dataSet) {
    vector<Data> scaledDataSet;

    computeMinMax();

    // scaling the dataSet
    for(auto data = dataSet.begin(); data != dataSet.end(); ++data) {
        Data scaledData;
        for(int i = 0; i < static_cast<int>(data->features.size()); ++i) {
            scaledData.features.push_back((data->features[i] - minFeatures[i]) / (maxFeatures[i] - minFeatures[i]));
        }

        for(int i = 0; i < static_cast<int>(data->targets.size()); ++i) {
            scaledData.targets.push_back((data->targets[i] - minTargets[i]) / (maxTargets[i] - minTargets[i]));
        }

        scaledDataSet.push_back(scaledData);
    }
    return scaledDataSet;
}
void DS18B20TempSensorThread::run()
{
    uint8_t data[9];

    ds->reset();             // On reset le bus 1-Wire
    ds->select(addr);        // On sélectionne le DS18B20

    ds->write(0x44, 1);      // On lance une prise de mesure de température
    delay(800);             // Et on attend la fin de la mesure

    ds->reset();             // On reset le bus 1-Wire
    ds->select(addr);        // On sélectionne le DS18B20
    ds->write(0xBE);         // On envoie une demande de lecture du scratchpad

    for (byte i = 0; i < 9; i++) // On lit le scratchpad
    data[i] = ds->read();       // Et on stock les octets reçus

    // Calcul de la température en degré Celsius
    temp = ((data[1] << 8) | data[0]) * 0.0625; 

    computeMinMax();
    runned();
}
vector<Data> DataSet::getScaledDataSet() {
    computeMinMax();
    return scale(DataSet::dataSet);
}
Example #10
0
std::vector<LinearLiteralPropagator::LinearConstraintClause> LinearLiteralPropagator::propagate_true(const ReifiedLinearConstraint& rl)
{
    const LinearConstraint& l = rl.l;
    assert(l.getRelation()==LinearConstraint::Relation::LE);
    std::vector<LinearConstraintClause> ret;
    LinearConstraintClause::itervec clause;
    auto minmax = computeMinMax(l, clause);
    if (minmax.second <= l.getRhs())
        return ret;

    //std::cout << "trying to propagate " << l << std::endl;
    auto views = l.getViews();
    for (std::size_t index=0; index < views.size(); ++index)
    {
        auto& i = views[index];
        auto wholeRange = vs_.getVariableStorage().getRestrictor(i);
        assert(wholeRange.size()>0);
        auto r = vs_.getVariableStorage().getCurrentRestrictor(i);
        std::pair<int64,int64> mm;
        mm.first = minmax.first - r.lower();
        mm.second = minmax.second - r.upper();
        
        //Literal prop = s_.falseLit();
        bool prop = false;
        Restrictor::ViewIterator propIt(wholeRange.begin());
        bool conflict = false;

        int64 up = l.getRhs() - mm.first;
        
        
        //// check if this returns the correct literals,
        /// see translatorClauseChecker::add, there is a positive and a negative add
        if (up < wholeRange.lower()) // derive false
        {
            //std::cout << "Constrain View " << i.v << "*" << i.a << "+" << i.c << " with new upper bound " << up << std::endl;
            propIt=wholeRange.begin();//can be removed
            conflict = true;
        }
        else
            if (up < r.upper())
            {
                //std::cout << "Constrain Variable " << i.v << "*" << i.a << "+" << i.c << " with new upper bound " << up << std::endl;
                auto newUpper = std::upper_bound(wholeRange.begin(), wholeRange.end(), up, [](int64 val, int64 it){ return it > val; });
                //assert(newUpper != r.end()); /// should never be able to happen, as up < r.upper().first, so there is something which is smaller, this means we do not need r ?
                if (newUpper==wholeRange.begin())
                {
                    propIt = newUpper;
                    conflict=true;
                }
                else
                {
                    propIt = newUpper;
                    --newUpper;
                    prop = true;
                    //prop = vs_.getVariableCreator().getLiteral(newUpper);
                    conflict = !constrainUpperBound((newUpper+1)); // +1 is needed, as it is an iterator pointing after the element
                    minmax.first = mm.first + r.lower();
                    minmax.second =  mm.second + *newUpper;
                    //minmax = mm + std::minmax(i.second*(int64)r.lower(),i.second*(int64)((*newUpper)));
                }
            }

        if (prop || conflict)
        {
            LinearConstraintClause c(rl);
            LinearConstraintClause::itervec aux(clause);
            aux[index] = propIt;
            c.setClause(std::move(aux),index);
            c.setConflict(conflict);
            ret.emplace_back(c);
        }
        if (conflict)
            break;
    }
    //When i changed a bound, the reason for the next ones can change, right ? No! only the upper/lower bound is changes, the other bound is used for reason
    return ret;
}
bool rspfSrtmSupportData::setFilename(const rspfFilename& srtmFile,
                                       bool scanForMinMax)
{
   theFile = srtmFile;

   if(traceDebug())
   {
      rspfNotify(rspfNotifyLevel_DEBUG)
         << "rspfSrtmSupportData::setFilename: entered:"
         << "\nsrtmFile:  " << srtmFile
         << "\nscanForMinMax flag:  " << scanForMinMax
         << std::endl;
   }
   
   theFileStream =  rspfStreamFactoryRegistry::instance()->
      createNewIFStream(theFile,
                        std::ios_base::in | std::ios_base::binary);
   if (theFileStream.valid())
   {
      if(theFileStream->fail())
      {
         if(traceDebug())
         {
            rspfNotify(rspfNotifyLevel_DEBUG)
               << theFile << " does not exist: leaving ..." << std::endl;
         }
         clear();
         return false;
      }
   }
   else
   {
      return false;
   }

   // Start with default.
   theMinPixelValue = DEFAULT_MIN;
   theMaxPixelValue = DEFAULT_MAX;
   
   // See if we have an rspf metadata file to initialize from.
   bool outputOmd     = false;
   bool loadedFromOmd = false;
   
   rspfFilename omdFile = theFile;
   omdFile.setExtension(rspfString("omd"));
   if (omdFile.exists())
   {
      //---
      // The loadOmd is called instead of loadState so theFile is not
      // overwrote.
      //---
      rspfKeywordlist kwl(omdFile);
      loadedFromOmd = loadOmd(kwl);
   }

   if (!loadedFromOmd)
   {
      if (!setCornerPoints())
      {
         clear();
         return false;
      }
      if (!setSize())
      {
         clear();
         return false;
      }
      outputOmd = true;
   }

   if (scanForMinMax)
   {
      // These could have been picked up in the loadOmd.
      if ( (theMinPixelValue == DEFAULT_MIN) ||
           (theMaxPixelValue == DEFAULT_MAX) )
      {
         if ( computeMinMax() )
         {
            outputOmd = true;
         }
         else
         {
            if(traceDebug())
            {
               rspfNotify(rspfNotifyLevel_DEBUG)
                  << "Unable to compute min max: leaving ..." << std::endl;
            }
            clear();
            return false;
         }
      }
   }

   //---
   // NOTE:  The outputOmd flag should probably be set if !loadedFromOmd.
   // Leaving as is for now (only set if scanForMinMax).
   //---
   if (outputOmd)
   {
      rspfKeywordlist kwl;
      saveState(kwl);
      kwl.write(omdFile);
   }

   if(theFileStream->is_open())
   {
      theFileStream->close();
   }
   
   if (traceDebug())
   {
      rspfNotify(rspfNotifyLevel_DEBUG) << *this << std::endl;
   }
   
   return true;
}
Example #12
0
bool toprsGadlReader::open()
{
	if(isOpen())
	{
		close();
	}
	std::string driverNameTmp;

	if (theSubDatasets.size() == 0)
	{
		// Note:  Cannot feed GDALOpen a NULL string!
		if (theImageFile.size())
		{
			theDataset = GDALOpen(theImageFile.c_str(), GA_ReadOnly); 
			if( theDataset == 0 )
			{
				return false;
			}
		}
		else
		{
			return false;
		}


		// Check if it is nitf data for deciding whether or not open each sub-dataset
		//This will be removed eventually when toprs can handle 2GB nitf file.
		GDALDriverH driverTmp = GDALGetDatasetDriver(theDataset);
		bool isNtif = false;
		if (driverTmp != 0)
		{
			driverNameTmp = std::string(GDALGetDriverShortName(driverTmp));
			std::transform(driverNameTmp.begin(), driverNameTmp.end(), driverNameTmp.begin(), [&](char ch){return toupper(ch);});
			if (driverNameTmp == "NITF")
			{
				isNtif = true;
			}
		}

		// Check for sub data sets...
		char** papszMetadata = GDALGetMetadata( theDataset, "SUBDATASETS" );
		if( CSLCount(papszMetadata) > 0 )
		{
			theSubDatasets.clear();

			for( int i = 0; papszMetadata[i] != 0; ++i )
			{
				std::string os = papszMetadata[i];
				if (os.find("_NAME=") != std::string::npos)
				{
					//Sub sets have already been set. Open each sub-dataset really slow down the process
					//specially for hdf data which sometimes has over 100 sub-datasets. Since following code
					//only for ntif cloud checking, so only open each sub-dataset here if the dataset is
					//nitf. This will be removed eventually when toprs can handle 2GB nitf file. 
					//Otherwise open a sub-dataset when setCurrentEntry() gets called.
					if (isNtif)
					{
						GDALDatasetH subDataset = GDALOpen(filterSubDatasetsString(os).c_str(),
							GA_ReadOnly);
						if ( subDataset != 0 )
						{
							// "Worldview ingest should ignore subimages when NITF_ICAT=CLOUD"
							// Hack: Ignore NITF subimages marked as cloud layers.
							std::string nitfIcatTag( GDALGetMetadataItem( subDataset, "NITF_ICAT", "" ) );
							if ( nitfIcatTag.find("CLOUD") == std::string::npos )
							{
								theSubDatasets.push_back(filterSubDatasetsString(os));
							}
						}
						GDALClose(subDataset);
					}
					else
					{
						theSubDatasets.push_back(filterSubDatasetsString(os));
					}
				}
			}
			//---
			// Have multiple entries.  We're going to default to open the first
			// entry like cidcadrg.
			//---
			close();

			theDataset = GDALOpen(theSubDatasets[theEntryNumberToRender].c_str(),
				GA_ReadOnly);
			if (theDataset == 0)
			{

				return false;
			}
		}  // End of has subsets block.

	}  // End of "if (theSubdatasets.size() == 0)"
	else
	{
		// Sub sets have already been set.
		theDataset = GDALOpen(theSubDatasets[theEntryNumberToRender].c_str(),
			GA_ReadOnly);
		if (theDataset == 0)
		{
			return false;
		}
	}

	// Set the driver.
	theDriver = GDALGetDatasetDriver( theDataset );

	if(!theDriver) return false;


	theGdtType = GDT_Byte;
	theOutputGdtType = GDT_Byte;

	if(getNumberOfInputBands() < 1 )
	{
		if(CSLCount(GDALGetMetadata(theDataset, "SUBDATASETS")))
		{
			std::cout
				<< "torsGdalReader::open WARNING:"
				<< "\nHas multiple sub datasets and need to set the data before"
				<< " we can get to the bands" << std::endl;
		}

		close();
		std::cout
			<< "torsGdalReader::open WARNING:"
			<< "\nNo band data present in torsGdalReader::open" << std::endl;
		return false;
	}

	toprs_int32 i = 0;
	GDALRasterBandH bBand = GDALGetRasterBand( theDataset, 1 );
	theGdtType  = GDALGetRasterDataType(bBand);


	char** papszMetadata = GDALGetMetadata( bBand, NULL );
	if (CSLCount(papszMetadata) > 0)
	{
		for(int i = 0; papszMetadata[i] != NULL; i++ )
		{
			std::string metaStr = papszMetadata[i];

			if (metaStr.find("AREA_OR_POINT") != std::string::npos)
			{
				//std::string pixel_is_point_or_area = metaStr.split("=")[1];
				//pixel_is_point_or_area.downcase();
				//if (pixel_is_point_or_area.contains("area"))
				//	thePixelType = TOPRS_PIXEL_IS_AREA;
				break;
			}
		}
	}

	if(!isIndexed(1))
	{
		for(i = 0; i  < GDALGetRasterCount(theDataset); ++i)
		{
			if(theGdtType != GDALGetRasterDataType(GDALGetRasterBand( theDataset,i+1 )))
			{
				std::cout
					<< "torsGdalReader::open WARNING"
					<< "\nWe currently do not support different scalar type bands."
					<< std::endl;
				close();
				return false;
			}

		}
	}
	theOutputGdtType = theGdtType;
	switch(theGdtType)
	{
	case GDT_CInt16:
		{
			//          theOutputGdtType = GDT_Int16;
			theIsComplexFlag = true;
			break;
		}
	case GDT_CInt32:
		{
			//          theOutputGdtType = GDT_Int32;
			theIsComplexFlag = true;
			break;
		}
	case GDT_CFloat32:
		{
			//          theOutputGdtType = GDT_Float32;
			theIsComplexFlag = true;
			break;
		}
	case GDT_CFloat64:
		{
			//          theOutputGdtType = GDT_Float64;
			theIsComplexFlag = true;
			break;
		}
	default:
		{
			theIsComplexFlag = false;
			break;
		}
	}

	if((std::string(GDALGetDriverShortName( theDriver )) == "PNG")&&
		(getNumberOfInputBands() == 4))
	{
		theAlphaChannelFlag = true;
	}
	populateLut();
	computeMinMax();
	completeOpen();

	theTile = toprsImgFactory::instance()->create(this);
	theSingleBandTile = toprsImgFactory::instance()->create(getInputScalarType(), 1);

	if ( m_preservePaletteIndexesFlag )
	{
		theTile->setIndexedFlag(true);
		theSingleBandTile->setIndexedFlag(true);
	}

	theTile->initialize();
	theSingleBandTile->initialize();
	theGdalBuffer.resize(0);
	if(theIsComplexFlag)
	{
		theGdalBuffer.resize(theSingleBandTile->getSizePerBandInBytes()*2);
	}

	theImageBound = toprsIRect(0
		,0
		,GDALGetRasterXSize(theDataset)-1
		,GDALGetRasterYSize(theDataset)-1);
	int xSize=0, ySize=0;
	GDALGetBlockSize(GDALGetRasterBand( theDataset, 1 ),
		&xSize,
		&ySize);
 
	if (driverNameTmp.find("JPIP")!= std::string::npos || driverNameTmp.find("JP2")!= std::string::npos)
	{
		m_isBlocked = ((xSize > 1)&&(ySize > 1));
	}
	else
	{
		m_isBlocked = false;
	}
	//if(m_isBlocked)
	//{
	//	setRlevelCache();
	//}
	return true;
}
Example #13
0
std::vector<std::vector<int>> ClintStmtOccurrence::projectOn(int horizontalDimIdx, int verticalDimIdx) const {
  if (m_oslScattering == nullptr) {
    std::cerr << "don't project" << std::endl;
  }
  CLINT_ASSERT(m_oslStatement != nullptr && m_oslScattering != nullptr,
               "Trying to project a non-initialized statement");

  // Transform iterator (alpha only) indices to enumerator (beta-alpha-beta) indices
  // betaDims are found properly iff the dimensionalityChecker assertion holds.
  int horizontalScatDimIdx    = 1 + 2 * horizontalDimIdx;
  int verticalScatDimIdx      = 1 + 2 * verticalDimIdx;
  int horizontalOrigDimIdx   = m_oslScattering->nb_output_dims + horizontalDimIdx;
  int verticalOrigDimIdx     = m_oslScattering->nb_output_dims + verticalDimIdx;

  horizontalScatDimIdx  = ignoreTilingDim(horizontalScatDimIdx);
  verticalScatDimIdx    = ignoreTilingDim(verticalScatDimIdx);
//  horizontalOrigDimIdx = ignoreTilingDim(horizontalOrigDimIdx);
//  verticalOrigDimIdx   = ignoreTilingDim(verticalOrigDimIdx);

  // Checking if all the relations for the same beta have the same structure.
  // AZ: Not sure if it is theoretically possible: statements with the same beta-vector
  // should normally be in the same part of the domain union and therefore have same
  // number of scattering variables.  If the following assertion ever fails, check the
  // theoretical statement and if it does not hold, perform enumeration separately for
  // each union part.
  // AZ: this holds for SCoPs generated by Clan.
  // TODO: piggyback on oslUtils and Enumerator to pass around the mapping from original iterators
  // to the scattering (indices in applied matrix) since different parts of the domain and scattering
  // relation unions may have different number of input/output dimensions for the codes
  // originating from outside Clan/Clay toolset.
  // AZ: is this even possible without extra information?  Two problematic cases,
  // 1. a1 = i + j, a2 = i - j; no clear mapping between a and i,j
  // 2. stripmine a1 >/< f(i), a2 = i; two a correspond to i in the same time.
  auto dimensionalityCheckerFunction = [](osl_relation_p rel, int output_dims,
                                          int input_dims, int parameters) {
    CLINT_ASSERT(rel->nb_output_dims == output_dims,
                 "Dimensionality mismatch, proper polyhedron construction impossible");
    CLINT_ASSERT(rel->nb_input_dims == input_dims,
                 "Dimensionality mismatch, proper polyhedron construction impossible");
    CLINT_ASSERT(rel->nb_parameters == parameters,
                 "Dimensionality mismatch, proper polyhedron construction impossible");
  };
  oslListForeach(m_oslStatement->domain, dimensionalityCheckerFunction, m_oslStatement->domain->nb_output_dims,
                 m_oslStatement->domain->nb_input_dims, m_oslStatement->domain->nb_parameters);
  CLINT_ASSERT(m_oslStatement->domain->nb_output_dims == m_oslScattering->nb_input_dims,
               "Scattering is not compatible with the domain");

  bool horizontalOrigDimValid = horizontalOrigDimIdx < m_oslScattering->nb_output_dims
      + m_oslStatement->domain->nb_output_dims;
  bool verticalOrigDimValid = verticalOrigDimIdx < m_oslScattering->nb_output_dims
      + m_oslStatement->domain->nb_output_dims;

  // Get original and scattered iterator values depending on the axis displayed.
  bool projectHorizontal = (horizontalDimIdx != -2) && (dimensionality() > horizontalDimIdx); // FIXME: -2 is in VizProperties::NO_DIMENSION, but should be in a different class since it has nothing to do with viz
  bool projectVertical   = (verticalDimIdx != -2) && (dimensionality() > verticalDimIdx);
  CLINT_ASSERT(!(projectHorizontal ^ (horizontalScatDimIdx >= 0 && horizontalScatDimIdx < m_oslScattering->nb_output_dims)),
               "Trying to project to the horizontal dimension that is not present in scattering");
  CLINT_ASSERT(!(projectVertical ^ (verticalScatDimIdx >= 0 && verticalScatDimIdx < m_oslScattering->nb_output_dims)),
               "Trying to project to the vertical dimension that is not present in scattering");

  std::vector<osl_relation_p> scatterings { m_oslScattering };
  osl_relation_p applied = oslApplyScattering(oslListToVector(m_oslStatement->domain),
                                              scatterings);
  osl_relation_p ready = oslRelationsWithContext(applied, m_statement->scop()->fixedContext());

  std::vector<int> allDimensions;
  allDimensions.reserve(m_oslScattering->nb_output_dims + 2);
  if (projectHorizontal && horizontalOrigDimValid) {
    allDimensions.push_back(horizontalScatDimIdx);
  }
  if (projectVertical && verticalOrigDimValid) {
    allDimensions.push_back(verticalScatDimIdx);
  }
  for (int i = 0, e = m_oslScattering->nb_input_dims; i < e; ++i) {
    allDimensions.push_back(m_oslScattering->nb_output_dims + i);
  }
  std::vector<std::vector<int>> points = program()->enumerator()->enumerate(ready, allDimensions);
  computeMinMax(points, horizontalDimIdx, verticalDimIdx);

  return std::move(points);
}
Example #14
0
void LinearLiteralPropagator::propagate_true(const ReifiedLinearConstraint& rl)
{
    const LinearConstraint& l = rl.l;
    assert(l.getRelation()==LinearConstraint::Relation::LE);

    propClause_.clear();
    auto minmax = computeMinMax(l, propClause_);
    if (minmax.second <= l.getRhs())
        return;

    if (conf_.propStrength<=2)
    {
        if (minmax.first > l.getRhs())
        {
            propClauses_.emplace_back(std::make_pair(~rl.v,std::move(propClause_)));
        }
        return;
    }

    //std::cout << "trying to propagate " << l << std::endl;
    auto& views = l.getViews();
    for (std::size_t index=0; index < views.size(); ++index)
    {
        auto& i = views[index];
        auto wholeRange = vs_.getVariableStorage().getRestrictor(i);
        assert(wholeRange.size()>0);
        auto r = vs_.getVariableStorage().getCurrentRestrictor(i);
        assert(r.begin() < r.end());
        std::pair<int64,int64> mm;
        mm.first = minmax.first - r.lower();
        mm.second = minmax.second - r.upper();

        //Literal prop = s_.falseLit();
        bool prop = false;
        Restrictor::ViewIterator propIt(wholeRange.begin());
        bool conflict = false;

        int64 up = l.getRhs() - mm.first;

        if (up < wholeRange.lower()) // derive false
        {
            //std::cout << "Constrain View " << i.v << "*" << i.a << "+" << i.c << " with new upper bound " << up << std::endl;
            //propIt=wholeRange.begin();//can be removed
            conflict = true;
        }
        else
            if (up < r.upper())
            {
                //std::cout << "Constrain Variable " << i.v << "*" << i.a << "+" << i.c << " with new upper bound " << up << std::endl;
                //std::cout << "This Variable before had domain " << r.lower() << " .. " << r.upper() << std::endl;
                auto newUpper = order::wrap_upper_bound(wholeRange.begin(), r.end(), up);
                //assert(newUpper != r.end()); /// should never be able to happen, as up < r.upper().first, so there is something which is smaller, this means we do not need r ?
                propIt = newUpper;
                if (newUpper==wholeRange.begin())
                {
                    conflict=true;
                }
                else
                {
                    --newUpper;
                    prop = true;
                    //prop = vs_.getVariableCreator().getLiteral(newUpper);
                    //std::cout << "the upper bound not included for this view will be " << *(newUpper+1) << std::endl;
                    conflict = !constrainUpperBound((newUpper+1)); // +1 is needed, as it is an iterator pointing after the element
                    //minmax.first = mm.first + r.lower();
                    minmax.second =  mm.second + *newUpper;
                    //minmax = mm + std::minmax(i.second*(int64)r.lower(),i.second*(int64)((*newUpper)));
                }
            }

        if (prop || conflict)
        {
            itervec aux;
            if (conflict) aux = std::move(propClause_);
            else aux = propClause_;
            aux[index] = propIt;
            propClauses_.emplace_back(std::make_pair(~rl.v,std::move(aux)));
        }
        if (conflict)
            break;
    }
    //When i changed a bound, the reason for the next ones can change, right ? No! only the upper/lower bound is changes, the other bound is used for reason
}
Example #15
0
bool ossimMrSidReader::open()
{
   static const char MODULE[] = "ossimMrSidReader::open";

   if (traceDebug())
   {
      ossimNotify(ossimNotifyLevel_DEBUG)
         << MODULE << " entered...\n"
         << "image: " << theImageFile << "\n";
   }
   
   bool result = false;

   if(isOpen())
   {
      closeEntry();
   }

   LT_STATUS sts = LT_STS_Uninit;

   const LTFileSpec fileSpec(theImageFile.c_str());
 
   theReader = MrSIDImageReader::create();
   sts = theReader->initialize(fileSpec, true);
   if (LT_SUCCESS(sts) == false)
   {
      return false;
   }

   theImageNavigator = new LTINavigator(*theReader);

   theImageRect = ossimIrect(0, 0, theReader->getWidth()-1, theReader->getHeight()-1);
   theNumberOfBands = theReader->getNumBands();
   theMinDwtLevels = theReader->getNumLevels();

   getDataType();

   if (getImageDimensions(theMrSidDims))
   {
      if (theScalarType != OSSIM_SCALAR_UNKNOWN)
      {
         ossim_uint32 width  = theReader->getWidth();
         ossim_uint32 height = theReader->getHeight();

         // Check for zero width, height.
         if ( !width || !height )
         {
            ossimIpt tileSize;
            ossim::defaultTileSize(tileSize);

            width  = tileSize.x;
            height = tileSize.y;
         }

         theTile = ossimImageDataFactory::instance()->create(this, this);

         theTile->initialize();

         // Call the base complete open to pick up overviews.
         computeMinMax();
         completeOpen();

         result = true;
      }
   }

   if (result == false)
   {
      closeEntry();
   }

   if (traceDebug())
   {
      ossimNotify(ossimNotifyLevel_DEBUG)
         << MODULE << " exit status = " << (result?"true":"false\n")
         << std::endl;
   }

   return result;
}