TEST(VIpTest, addTest) { VIp ip1(1111); VIp ip2(2222); VIp ip3 = ip1 + ip2; EXPECT_TRUE(ip3 == 3333); }
void ScalarFiniteElement<D> :: CalcDDShape (const IntegrationPoint & ip, FlatMatrix<> ddshape) const { int nd = GetNDof(); int sdim = D; double eps = 1e-7; Matrix<> dshape1(nd, sdim), dshape2(nd, sdim); for (int i = 0; i < sdim; i++) { IntegrationPoint ip1 = ip; IntegrationPoint ip2 = ip; ip1(i) -= eps; ip2(i) += eps; CalcDShape (ip1, dshape1); CalcDShape (ip2, dshape2); dshape2 -= dshape1; dshape2 *= (0.5 / eps); for (int j = 0; j < nd; j++) for (int k = 0; k < sdim; k++) ddshape(j,sdim*i+k) = dshape2(j,k); } }
void ScalarFiniteElement<D> :: CalcDShape (const IntegrationPoint & ip, FlatMatrixFixWidth<D> dshape) const { static bool firsttime = true; if (firsttime) { cout << "WARNING: CalcDShape not overloaded for class, using numerical differentiation " << typeid(this).name() << ", ndof = " << ndof << endl; firsttime = false; } int nd = GetNDof(); int sdim = D; double eps = 2e-5; ArrayMem<double, 100> hm1(nd), hm2(nd), hm3(nd), hm4(nd); FlatVector<> shape1(nd, &hm1[0]), shape2(nd, &hm2[0]), shape3(nd, &hm3[0]), shape4(nd, &hm4[0]); for (int i = 0; i < sdim; i++) { IntegrationPoint ip1 = ip; IntegrationPoint ip2 = ip; ip1(i) -= eps; ip2(i) += eps; CalcShape (ip1, shape1); CalcShape (ip2, shape2); ip1(i) -= eps; ip2(i) += eps; CalcShape (ip1, shape3); CalcShape (ip2, shape4); for (int j = 0; j < nd; j++) dshape(j, i) = 2/(3*eps) * (shape2(j) - shape1(j)) -1/(12*eps) * (shape4(j) - shape3(j)); } }
std::tuple<I0, I1, O> operator()(I0 begin0, iterator_difference_t<I0> n0, I1 begin1, iterator_difference_t<I1> n1, O out, C r = C{}, P0 p0 = P0{}, P1 p1 = P1{}) const { using T = std::tuple<I0, I1, O>; auto &&ir = invokable(r); auto &&ip0 = invokable(p0); auto &&ip1 = invokable(p1); auto n0orig = n0; auto n1orig = n1; auto b0 = uncounted(begin0); auto b1 = uncounted(begin1); while(true) { if(0 == n0) { auto res = copy_n(b1, n1, out); begin0 = recounted(begin0, b0, n0orig); begin1 = recounted(begin1, res.first, n1orig); return T{begin0, begin1, res.second}; } if(0 == n1) { auto res = copy_n(b0, n0, out); begin0 = recounted(begin0, res.first, n0orig); begin1 = recounted(begin1, b1, n1orig); return T{begin0, begin1, res.second}; } if(ir(ip1(*b1), ip0(*b0))) { *out = *b1; ++b1; ++out; --n1; } else { *out = *b0; ++b0; ++out; --n0; } } }
/*! Display the result of the matching. The plane is displayed in red and the points of interests detected in the image are shown by a red dot surrounded by a green circle (the radius of the circle depends on the octave at which it has been detected). \param I : The gray scaled image for the display. \param displayKpts : The flag to display keypoints in addition to the surface. */ void vpPlanarObjectDetector::display(vpImage<unsigned char> &I, bool displayKpts) { for(unsigned int i=0; i<dst_corners.size(); i++){ vpImagePoint ip1( dst_corners[i].y - modelROI.y, dst_corners[i].x - modelROI.x); vpImagePoint ip2( dst_corners[(i+1)%dst_corners.size()].y - modelROI.y, dst_corners[(i+1)%dst_corners.size()].x - modelROI.x); vpDisplay::displayLine(I, ip1, ip2, vpColor::red) ; } if(displayKpts){ for(unsigned int i=0; i<currentImagePoints.size(); ++i){ vpImagePoint ip( currentImagePoints[i].get_i() - modelROI.y, currentImagePoints[i].get_j() - modelROI.x); vpDisplay::displayCross(I, ip, 5, vpColor::red); } } }
void ScalarFiniteElement<D> :: CalcMappedDDShape (const MappedIntegrationPoint<D,D> & mip, FlatMatrix<> ddshape) const { int nd = GetNDof(); double eps = 1e-7; MatrixFixWidth<D> dshape1(nd), dshape2(nd); const ElementTransformation & eltrans = mip.GetTransformation(); for (int i = 0; i < D; i++) { IntegrationPoint ip1 = mip.IP(); IntegrationPoint ip2 = mip.IP(); ip1(i) -= eps; ip2(i) += eps; MappedIntegrationPoint<D,D> mip1(ip1, eltrans); MappedIntegrationPoint<D,D> mip2(ip2, eltrans); CalcMappedDShape (mip1, dshape1); CalcMappedDShape (mip2, dshape2); ddshape.Cols(D*i,D*(i+1)) = (0.5/eps) * (dshape2-dshape1); } for (int j = 0; j < D; j++) { for (int k = 0; k < nd; k++) for (int l = 0; l < D; l++) dshape1(k,l) = ddshape(k, l*D+j); dshape2 = dshape1 * mip.GetJacobianInverse(); for (int k = 0; k < nd; k++) for (int l = 0; l < D; l++) ddshape(k, l*D+j) = dshape2(k,l); } }
TEST(VIpTest, copyTest) { VIp ip1(1234); VIp ip2 = ip1; EXPECT_TRUE(ip2 == 1234); }
bool rspfNitfRpcModel::parseImageHeader(const rspfNitfImageHeader* ih) { if (getRpcData(ih) == false) { if (traceDebug()) { rspfNotify(rspfNotifyLevel_DEBUG) << "rspfNitfRpcModel::parseFile DEBUG:" << "\nError parsing rpc tags. Aborting with error." << std::endl; } setErrorStatus(); return false; } rspfString os = ih->getImageMagnification(); if ( os.contains("/") ) { os = os.after("/"); rspf_float64 d = os.toFloat64(); if (d) { theDecimation = 1.0 / d; } } theImageID = ih->getImageId(); rspfIrect imageRect = ih->getImageRect(); theImageSize.line = static_cast<rspf_int32>(imageRect.height() / theDecimation); theImageSize.samp = static_cast<rspf_int32>(imageRect.width() / theDecimation); getSensorID(ih); theRefImgPt.line = theImageSize.line/2.0; theRefImgPt.samp = theImageSize.samp/2.0; theRefGndPt.lat = theLatOffset; theRefGndPt.lon = theLonOffset; theRefGndPt.hgt = theHgtOffset; theImageClipRect = rspfDrect(0.0, 0.0, theImageSize.samp-1, theImageSize.line-1); rspfGpt v0, v1, v2, v3; rspfDpt ip0 (0.0, 0.0); rspfRpcModel::lineSampleHeightToWorld(ip0, theHgtOffset, v0); rspfDpt ip1 (theImageSize.samp-1.0, 0.0); rspfRpcModel::lineSampleHeightToWorld(ip1, theHgtOffset, v1); rspfDpt ip2 (theImageSize.samp-1.0, theImageSize.line-1.0); rspfRpcModel::lineSampleHeightToWorld(ip2, theHgtOffset, v2); rspfDpt ip3 (0.0, theImageSize.line-1.0); rspfRpcModel::lineSampleHeightToWorld(ip3, theHgtOffset, v3); theBoundGndPolygon = rspfPolygon (rspfDpt(v0), rspfDpt(v1), rspfDpt(v2), rspfDpt(v3)); updateModel(); rspfRpcModel::lineSampleHeightToWorld(theRefImgPt, theHgtOffset, theRefGndPt); if ( theRefGndPt.isLatNan() || theRefGndPt.isLonNan() ) { if (traceDebug()) { rspfNotify(rspfNotifyLevel_DEBUG) << "rspfNitfRpcModel::rspfNitfRpcModel DEBUG:" << "\nGround Reference Point not valid." << " Aborting with error..." << std::endl; } setErrorStatus(); return false; } try { computeGsd(); } catch (const rspfException& e) { if (traceDebug()) { rspfNotify(rspfNotifyLevel_DEBUG) << "rspfNitfRpcModel::rspfNitfRpcModel DEBUG:\n" << e.what() << std::endl; } } if (traceExec()) { rspfNotify(rspfNotifyLevel_DEBUG) << "DEBUG rspfNitfRpcModel::parseFile: returning..." << std::endl; } return true; }
bool ossimNitfRsmModel::parseImageHeader(const ossimNitfImageHeader* ih) { static const char MODULE[] = "ossimNitfRsmModel::getRsmData"; if (traceExec()) { ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " entering..." << std::endl; } bool status = false; if ( getRsmData(ih) ) { theImageID = m_iid.trim(); ossimIrect imageRect = ih->getImageRect(); // Fetch Image Size: theImageSize.line = static_cast<ossim_int32>(imageRect.height()); theImageSize.samp = static_cast<ossim_int32>(imageRect.width()); // Assign other data members: theRefImgPt.line = theImageSize.line/2.0; theRefImgPt.samp = theImageSize.samp/2.0; // Assign the bounding image space rectangle: theImageClipRect = ossimDrect(0.0, 0.0, theImageSize.samp-1, theImageSize.line-1); ossimGpt v0, v1, v2, v3; ossimDpt ip0 (0.0, 0.0); lineSampleHeightToWorld(ip0, m_znrmo, v0); ossimDpt ip1 (theImageSize.samp-1.0, 0.0); lineSampleHeightToWorld(ip1, m_znrmo, v1); ossimDpt ip2 (theImageSize.samp-1.0, theImageSize.line-1.0); lineSampleHeightToWorld(ip2, m_znrmo, v2); ossimDpt ip3 (0.0, theImageSize.line-1.0); lineSampleHeightToWorld(ip3, m_znrmo, v3); theBoundGndPolygon = ossimPolygon (ossimDpt(v0), ossimDpt(v1), ossimDpt(v2), ossimDpt(v3)); updateModel(); // Set the ground reference point. lineSampleHeightToWorld(theRefImgPt, m_znrmo, theRefGndPt); // Height could have nan if elevation is not set so check lat, lon individually. if ( ( theRefGndPt.isLatNan() == false ) && ( theRefGndPt.isLonNan() == false ) ) { //--- // This will set theGSD and theMeanGSD. This model doesn't need these but // others do. //--- try { computeGsd(); // Set return status. status = true; } catch (const ossimException& e) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimNitfRpcModel::ossimNitfRpcModel DEBUG:\n" << e.what() << std::endl; } setErrorStatus(); } } else { if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimNitfRpcModel::ossimNitfRpcModel DEBUG:" << "\nGround Reference Point not valid(has nans)." << " Aborting with error..." << std::endl; } setErrorStatus(); } } else { if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimNitfRpcModel::parseFile DEBUG:" << "\nError parsing rsm tags. Aborting with error." << std::endl; } setErrorStatus(); } if (traceExec()) { ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " exit status: " << ( status ? "true" : "false" ) << "\n"; } return status; } // End: ossimNitfRsmModel::parseImageHeader(const ossimNitfImageHeader* ih)
IPropertyTree* CFileSpraySoapBindingEx::createPTreeForXslt(const char* method, const char* dfuwuid) { Owned<IEnvironmentFactory> factory = getEnvironmentFactory(); Owned<IConstEnvironment> m_constEnv = factory->openEnvironment(); Owned<IPropertyTree> pEnvRoot = &m_constEnv->getPTree(); IPropertyTree* pEnvSoftware = pEnvRoot->queryPropTree("Software"); Owned<IPropertyTree> pRoot = createPTreeFromXMLString("<Environment/>"); IPropertyTree* pSoftware = pRoot->addPropTree("Software", createPTree("Software")); if (pEnvSoftware) { StringBuffer dfuwuidSourcePartIP, wuxml; if(dfuwuid && *dfuwuid) { Owned<IDFUWorkUnitFactory> dfuwu_factory = getDFUWorkUnitFactory(); Owned<IConstDFUWorkUnit> dfuwu = dfuwu_factory->openWorkUnit(dfuwuid, false); if(dfuwu) { dfuwu->toXML(wuxml); Owned<IPropertyTree> wu = createPTreeFromXMLString(wuxml.str()); if (wu) { const char* ip = wu->queryProp("Source/Part/@node"); if (ip && *ip) dfuwuidSourcePartIP.append(ip); } } } Owned<IPropertyTreeIterator> it = pEnvSoftware->getElements("DropZone"); ForEach(*it) { IPropertyTree* pDropZone = pSoftware->addPropTree("DropZone", &it->get()); //get IP Address of the computer associated with this drop zone const char* pszComputer = it->query().queryProp("@computer"); if (!strcmp(pszComputer, ".")) pszComputer = "localhost"; StringBuffer xpath; xpath.appendf("Hardware/Computer[@name='%s']/@netAddress", pszComputer); StringBuffer sNetAddr; const char* pszNetAddr = pEnvRoot->queryProp(xpath.str()); if (strcmp(pszNetAddr, ".")) { sNetAddr.append(pszNetAddr); } else { StringBuffer ipStr; IpAddress ipaddr = queryHostIP(); ipaddr.getIpText(ipStr); if (ipStr.length() > 0) { #ifdef MACHINE_IP sNetAddr.append(MACHINE_IP); #else sNetAddr.append(ipStr.str()); #endif } } pDropZone->addProp("@netAddress", sNetAddr.str()); if ((dfuwuidSourcePartIP.length() > 0) && (sNetAddr.length() > 0)) { IpAddress ip1(dfuwuidSourcePartIP.str()), ip2(sNetAddr.str()); if (ip1.ipequals(ip2)) pDropZone->addProp("@sourceNode", "1"); } Owned<IConstMachineInfo> machine; if (strcmp(pszNetAddr, ".")) machine.setown(m_constEnv->getMachineByAddress(sNetAddr.str())); else { machine.setown(m_constEnv->getMachineByAddress(pszNetAddr)); if (!machine) machine.setown(m_constEnv->getMachineByAddress(sNetAddr.str())); } if (machine) { //int os = machine->getOS(); StringBuffer dir; pDropZone->getProp("@directory", dir); if (machine->getOS() == MachineOsLinux || machine->getOS() == MachineOsSolaris) { dir.replace('\\', '/');//replace all '\\' by '/' pDropZone->setProp("@linux", "true"); } else { dir.replace('/', '\\'); dir.replace('$', ':'); } pDropZone->setProp("@directory", dir); } } //For Spray files on Thor Cluster, fetch all the group names for all the thor instances (and dedup them) BoolHash uniqueThorClusterGroupNames; it.setown(pEnvSoftware->getElements("ThorCluster")); ForEach(*it) { StringBuffer thorClusterGroupName; IPropertyTree& cluster = it->query(); getClusterGroupName(cluster, thorClusterGroupName); if (!thorClusterGroupName.length()) continue; bool* found = uniqueThorClusterGroupNames.getValue(thorClusterGroupName.str()); if (found && *found) continue; uniqueThorClusterGroupNames.setValue(thorClusterGroupName.str(), true); IPropertyTree* newClusterTree = pSoftware->addPropTree("ThorCluster", &it->get()); newClusterTree->setProp("@name", thorClusterGroupName.str()); //set group name into @name for spray target } it.setown(pEnvSoftware->getElements("EclAgentProcess")); ForEach(*it) { IPropertyTree &cluster = it->query(); const char* name = cluster.queryProp("@name"); if (!name||!*name) continue; unsigned ins = 0; Owned<IPropertyTreeIterator> insts = cluster.getElements("Instance"); ForEach(*insts) { const char *na = insts->query().queryProp("@netAddress"); if (!na || !*na) { insts->query().setProp("@gname", name); continue; } SocketEndpoint ep(na); if (ep.isNull()) continue; ins++; StringBuffer gname("hthor__"); //StringBuffer gname; gname.append(name); if (ins>1) gname.append('_').append(ins); insts->query().setProp("@gname", gname.str()); } pSoftware->addPropTree("EclAgentProcess", &it->get()); } if (stricmp(method, "CopyInput") == 0) //Limit for this method only { it.setown(pEnvSoftware->getElements("RoxieCluster")); ForEach(*it) pSoftware->addPropTree("RoxieCluster", &it->get()); } if (wuxml.length() > 0) pSoftware->addPropTree("DfuWorkunit", createPTreeFromXMLString(wuxml.str())); } return pRoot.getClear(); }
bool ossimNitfRpcModel::parseImageHeader(const ossimNitfImageHeader* ih) { // Do this first so we don't waste time if not rpc image. if (getRpcData(ih) == false) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimNitfRpcModel::parseFile DEBUG:" << "\nError parsing rpc tags. Aborting with error." << std::endl; } setErrorStatus(); return false; } //--- // Get the decimation if any from the header "IMAG" field. // // Look for string like: // "/2" = 1/2 // "/4 = 1/4 // ... // "/16 = 1/16 // If it is full resolution it should be "1.0" //--- ossimString os = ih->getImageMagnification(); if ( os.contains("/") ) { os = os.after("/"); ossim_float64 d = os.toFloat64(); if (d) { theDecimation = 1.0 / d; } } //*** // Fetch Image ID: //*** theImageID = ih->getImageId(); ossimIrect imageRect = ih->getImageRect(); //--- // Fetch Image Size: //--- theImageSize.line = static_cast<ossim_int32>(imageRect.height() / theDecimation); theImageSize.samp = static_cast<ossim_int32>(imageRect.width() / theDecimation); // Search for the STDID Tag to fetch mission (satellite) name: getSensorID(ih); //*** // Assign other data members: //*** theRefImgPt.line = theImageSize.line/2.0; theRefImgPt.samp = theImageSize.samp/2.0; theRefGndPt.lat = theLatOffset; theRefGndPt.lon = theLonOffset; theRefGndPt.hgt = theHgtOffset; //*** // Assign the bounding image space rectangle: //*** theImageClipRect = ossimDrect(0.0, 0.0, theImageSize.samp-1, theImageSize.line-1); //--- // Assign the bounding ground polygon: // // NOTE: We will use the base ossimRpcModel for transformation since all // of our calls are in full image space (not decimated). //--- ossimGpt v0, v1, v2, v3; ossimDpt ip0 (0.0, 0.0); ossimRpcModel::lineSampleHeightToWorld(ip0, theHgtOffset, v0); ossimDpt ip1 (theImageSize.samp-1.0, 0.0); ossimRpcModel::lineSampleHeightToWorld(ip1, theHgtOffset, v1); ossimDpt ip2 (theImageSize.samp-1.0, theImageSize.line-1.0); ossimRpcModel::lineSampleHeightToWorld(ip2, theHgtOffset, v2); ossimDpt ip3 (0.0, theImageSize.line-1.0); ossimRpcModel::lineSampleHeightToWorld(ip3, theHgtOffset, v3); theBoundGndPolygon = ossimPolygon (ossimDpt(v0), ossimDpt(v1), ossimDpt(v2), ossimDpt(v3)); updateModel(); // Set the ground reference point. ossimRpcModel::lineSampleHeightToWorld(theRefImgPt, theHgtOffset, theRefGndPt); if ( theRefGndPt.isLatNan() || theRefGndPt.isLonNan() ) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimNitfRpcModel::ossimNitfRpcModel DEBUG:" << "\nGround Reference Point not valid." << " Aborting with error..." << std::endl; } setErrorStatus(); return false; } //--- // This will set theGSD and theMeanGSD. This model doesn't need these but // others do. //--- try { computeGsd(); } catch (const ossimException& e) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimNitfRpcModel::ossimNitfRpcModel DEBUG:\n" << e.what() << std::endl; } } if (traceExec()) { ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimNitfRpcModel::parseFile: returning..." << std::endl; } return true; }
//***************************************************************************** // METHOD: ossimIkonosRpcModel::finishConstruction() // //***************************************************************************** void ossimIkonosRpcModel::finishConstruction() { if (traceExec()) { ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimIkonosRpcModel finishConstruction(): entering..." << std::endl; } //*** // Assign other data members: //*** thePolyType = B; // This may not be true for early RPC imagery theRefImgPt.line = theLineOffset; theRefImgPt.samp = theSampOffset; theRefGndPt.lat = theLatOffset; theRefGndPt.lon = theLonOffset; theRefGndPt.hgt = theHgtOffset; //*** // Assign the bounding image space rectangle: //*** theImageClipRect = ossimDrect(0.0, 0.0, theImageSize.samp-1, theImageSize.line-1); //--- // NOTE: We must call "updateModel()" to set parameter used by base // ossimRpcModel prior to calling lineSampleHeightToWorld or all // the world points will be same. //--- updateModel(); //*** // Assign the bounding ground polygon: //*** ossimGpt v0, v1, v2, v3; ossimDpt ip0 (0.0, 0.0); lineSampleHeightToWorld(ip0, 0.0, v0); ossimDpt ip1 (theImageSize.samp-1.0, 0.0); lineSampleHeightToWorld(ip1, 0.0, v1); ossimDpt ip2 (theImageSize.samp-1.0, theImageSize.line-1.0); lineSampleHeightToWorld(ip2, 0.0, v2); ossimDpt ip3 (0.0, theImageSize.line-1.0); lineSampleHeightToWorld(ip3, 0.0, v3); theBoundGndPolygon = ossimPolygon (ossimDpt(v0), ossimDpt(v1), ossimDpt(v2), ossimDpt(v3)); //--- // Call compute gsd: // // This will set theGSD and theMeanGSD using lineSampleHeightToWorld on // three image points. Previously this was pulled from metadata. Some of // which was in US Survey feet and not converted to meters. This method // is more accurate as it uses the sensor model to compute. //--- try { // Method throws ossimException. computeGsd(); } catch (const ossimException& e) { ossimNotify(ossimNotifyLevel_WARN) << "ossimIkonosRpcModel finishConstruction Caught Exception:\n" << e.what() << std::endl; } if (traceExec()) { ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimIkonosRpcModel finishConstruction(): returning..." << std::endl; } }