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); } }
void run() { IntPair ip; test_(ip.getX() == 0 && ip.getY() == 0); IntPair ip2(3,-5); test_(ip2.getX() == 3 && ip2.getY() == -5); IntPair ip3 = ip2; test_(ip3.getX() == 3 && ip3.getY() == -5); IntPair ip4 = ip3 + ip2; test_(ip4.getX() == 6 && ip4.getY() == -10); test_(ip2 == ip4 - ip3); test_(ip3 < ip4); IntPair ip5(6,-4); test_(ip5 > ip4); test_(ip4 < ip5); test_((ip4 + ip5) == (ip5 + ip4)); Direction left = Direction(Direction::LEFT); test_(*(left.getDirPair()) == IntPair(-1,0)); test_(*(left.getDirPair()) < IntPair(0,0)); Direction right = Direction(); test_(*(right.getDirPair()) == IntPair(1,0)); //Direction::initialize(); int n = Direction::getRandom().getNo(); test_(n < 4 && n >=0); n = Direction::getRandom().getNo(); test_(n < 4 && n >=0); n = Direction::getRandom().getNo(); test_(n < 4 && n >=0); n = Direction::getRandom().getNo(); test_(n < 4 && n >=0); n = Direction::getRandom().getNo(); test_(n < 4 && n >=0); n = Direction::getRandomNew(Direction(Direction::RIGHT)).getNo(); test_(n < 4 && n >=0 && n != 2); n = Direction::getRandomNew(Direction::UP).getNo(); test_(n < 4 && n >=0 && n != 3); n = Direction::getRandomNew(Direction::LEFT).getNo(); test_(n < 4 && n >=0 && n != 0); n = Direction::getRandomNew(Direction::DOWN).getNo(); test_(n < 4 && n >=0 && n != 1); ip4.print(); Direction up = Direction(IntPair(0,1)); test_(up.getNo() == Direction::UP); left = Direction(IntPair(-1,0)); test_(left.getNo() == Direction::LEFT); Direction child = Direction::getFirstChild(up); test_(child.getNo() == Direction::RIGHT); Direction child2 = Direction::getSecondChild(up); test_(child2.getNo() == Direction::UP); child2 = Direction::getNextChild(up, child); test_(child2.getNo() == Direction::UP); Direction child3 = Direction::getThirdChild(up); test_(child3.getNo() == Direction::LEFT); child3 = Direction::getNextChild(up, child2); test_(child3.getNo() == Direction::LEFT); Direction down(Direction::DOWN); child = Direction::getFirstChild(down); test_(child.getNo() == Direction::LEFT); child2 = Direction::getSecondChild(down); test_(child2.getNo() == Direction::DOWN); child2 = Direction::getNextChild(down, child); test_(child2.getNo() == Direction::DOWN); child3 = Direction::getThirdChild(down); test_(child3.getNo() == Direction::RIGHT); child = Direction::getFirstChild(left); test_(child.getNo() == Direction::UP); child = Direction::getNextChild(left, child); test_(child.getNo() == Direction::LEFT); child = Direction::getNextChild(left, child); test_(child.getNo() == Direction::DOWN); right = Direction(IntPair(1,0)); child = Direction::getFirstChild(right); test_(child.getNo() == Direction::DOWN); child2 = Direction::getSecondChild(right); test_(child2.getNo() == Direction::RIGHT); child2 = Direction::getNextChild(right, child); test_(child2.getNo() == Direction::RIGHT); child3 = Direction::getThirdChild(right); test_(child3.getNo() == Direction::UP); IntPair ip10 = IntPair(-1,+20); IntPair ip11 = IntPair::parseIntPair("(-1,+20)"); test_(ip10 == ip11); }
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)
EXPORT int i_polar_2( Locstate ahead, Locstate behind, Locstate refl_bow, Locstate refl_mach, ANGLE_DIRECTION i_to_a_dir, float *abs_v, float aw_ang, float inc_ang, float *refl_ang, float *contact_ang, float Mach_ang) { IP2_PARAMS ip2_params; float inc_shock_speed; float node_speed; float node_ang, ans; float min_ang, max_ang; float i_n[SMAXD]; /* inc shock normal points to ahead */ float delta, epsilon; const float meps = MACH_EPS; debug_print("ipolar2","Entered i_polar_2()\n"); #if defined(DEBUG_GIPOLAR) if (debugging("ipolar2")) { verbose_print_state("ahead",ahead); verbose_print_state("behind",behind); print_angle("inc_ang =", inc_ang,"\n"); print_angle("Mach_ang =",Mach_ang,"\n"); print_angle_direction("\ti_to_a_dir =",i_to_a_dir,"\n"); } #endif /* defined(DEBUG_GIPOLAR) */ /* Find incident shock speed */ if (i_to_a_dir == COUNTER_CLOCK) { i_n[0] = cos(inc_ang + PI / 2.); i_n[1] = sin(inc_ang + PI / 2.); min_ang = inc_ang; max_ang = aw_ang; } else { i_n[0] = cos(inc_ang - PI / 2.); i_n[1] = sin(inc_ang - PI / 2.); min_ang = aw_ang; max_ang = inc_ang; } (void) s_polar_4(BEHIND_PRESSURE,pressure(behind), &inc_shock_speed,i_n,ahead,behind,GAS_STATE); #if defined(DEBUG_GIPOLAR) if (debugging("ipolar2")) { print_angle("min_ang =", min_ang,"\n"); print_angle("max_ang =",max_ang,"\n"); (void) printf("inc_shock_speed = %g\n",inc_shock_speed); } #endif /* defined(DEBUG_GIPOLAR) */ /* Initialize ip2_params */ ip2_params.ahead = ahead; ip2_params.behind = behind; ip2_params.refl_bow = refl_bow; ip2_params.refl_mach = refl_mach; ip2_params.inc_shock_speed = inc_shock_speed; ip2_params.inc_ang = inc_ang; ip2_params.refl_ang = refl_ang; ip2_params.contact_ang = contact_ang; ip2_params.Mach_ang = Mach_ang; ip2_params.i_to_a_dir = i_to_a_dir; /* Solve for node_angle */ if (min_ang > max_ang) min_ang -= 2. * PI; delta = EPS*fabs(max_ang-min_ang); delta = max(delta, meps); (void) ip2(0.5*(max_ang+min_ang), &epsilon, (POINTER) &ip2_params); epsilon = fabs(epsilon)*EPS; epsilon = max(epsilon, meps); if (debugging("ip2_vals")) { print_function_values(ip2,(POINTER) &ip2_params, 0.0,min_ang,max_ang,100,"ip2",stdout); } if (find_root(ip2,(POINTER)&ip2_params,0.0,&node_ang, min_ang,max_ang,epsilon,delta) == FUNCTION_FAILED) return NO; /* Since ip2() is a discontinuous function, the root finder may find an invalid root at the point of discontinuity. Check for this. */ (void) ip2(node_ang,&ans,(POINTER) &ip2_params); if (fabs(ans) > epsilon) { if (debugging("ipolar2")) { screen("WARNING in i_polar_2(), "); screen("root_finder returned invalid root\n"); } return NO; } /* Determine node velocity */ node_speed = inc_shock_speed/fabs(sin(inc_ang - node_ang)); abs_v[0] = node_speed * cos(node_ang); abs_v[1] = node_speed * sin(node_ang); debug_print("ipolar2","Left i_polar_2()\n"); return YES; } /*end i_polar_2*/
TYPED_TEST(NeuronLayerTest, TestPReLUInPlace) { typedef typename TypeParam::Dtype Dtype; // Set layer parameters LayerParameter ip_layer_param; LayerParameter prelu_layer_param; InnerProductParameter *ip_param = ip_layer_param.mutable_inner_product_param(); ip_param->mutable_weight_filler()->set_type("gaussian"); ip_param->set_num_output(3); InnerProductLayer<Dtype> ip(ip_layer_param); PReLULayer<Dtype> prelu(prelu_layer_param); InnerProductLayer<Dtype> ip2(ip_layer_param); PReLULayer<Dtype> prelu2(prelu_layer_param); // Set up blobs vector<Blob<Dtype>*> blob_bottom_vec_2; vector<Blob<Dtype>*> blob_middle_vec_2; vector<Blob<Dtype>*> blob_top_vec_2; shared_ptr<Blob<Dtype> > blob_bottom_2(new Blob<Dtype>()); shared_ptr<Blob<Dtype> > blob_middle_2(new Blob<Dtype>()); shared_ptr<Blob<Dtype> > blob_top_2(new Blob<Dtype>()); blob_bottom_vec_2.push_back(blob_bottom_2.get()); blob_middle_vec_2.push_back(blob_middle_2.get()); blob_top_vec_2.push_back(blob_top_2.get()); blob_bottom_2->CopyFrom(*this->blob_bottom_, false, true); // SetUp layers ip.SetUp(this->blob_bottom_vec_, this->blob_top_vec_); prelu.SetUp(this->blob_top_vec_, this->blob_top_vec_); ip2.SetUp(blob_bottom_vec_2, blob_middle_vec_2); prelu2.SetUp(blob_middle_vec_2, blob_top_vec_2); caffe_copy(ip2.blobs()[0]->count(), ip.blobs()[0]->cpu_data(), ip2.blobs()[0]->mutable_cpu_data()); // Forward in-place ip.Reshape(this->blob_bottom_vec_, this->blob_top_vec_); ip.Forward(this->blob_bottom_vec_, this->blob_top_vec_); prelu.Reshape(this->blob_top_vec_, this->blob_top_vec_); prelu.Forward(this->blob_top_vec_, this->blob_top_vec_); // Forward non-in-place ip2.Reshape(blob_bottom_vec_2, blob_middle_vec_2); ip2.Forward(blob_bottom_vec_2, blob_middle_vec_2); prelu2.Reshape(blob_middle_vec_2, blob_top_vec_2); prelu2.Forward(blob_middle_vec_2, blob_top_vec_2); // Check numbers for (int s = 0; s < blob_top_2->count(); ++s) { EXPECT_EQ(this->blob_top_->cpu_data()[s], blob_top_2->cpu_data()[s]); } // Fill top diff with random numbers shared_ptr<Blob<Dtype> > tmp_blob(new Blob<Dtype>()); tmp_blob->ReshapeLike(*blob_top_2.get()); FillerParameter filler_param; GaussianFiller<Dtype> filler(filler_param); filler.Fill(tmp_blob.get()); caffe_copy(blob_top_2->count(), tmp_blob->cpu_data(), this->blob_top_->mutable_cpu_diff()); caffe_copy(blob_top_2->count(), tmp_blob->cpu_data(), blob_top_2->mutable_cpu_diff()); // Backward in-place vector<bool> propagate_down; propagate_down.push_back(true); prelu.Backward(this->blob_top_vec_, propagate_down, this->blob_top_vec_); ip.Backward(this->blob_top_vec_, propagate_down, this->blob_bottom_vec_); // Backward non-in-place prelu2.Backward(blob_top_vec_2, propagate_down, blob_middle_vec_2); ip2.Backward(blob_middle_vec_2, propagate_down, blob_bottom_vec_2); // Check numbers for (int s = 0; s < blob_bottom_2->count(); ++s) { EXPECT_EQ(this->blob_bottom_->cpu_diff()[s], blob_bottom_2->cpu_diff()[s]); } for (int s = 0; s < ip.blobs()[0]->count(); ++s) { EXPECT_EQ(ip.blobs()[0]->cpu_diff()[s], ip2.blobs()[0]->cpu_diff()[s]); } for (int s = 0; s < ip.blobs()[1]->count(); ++s) { EXPECT_EQ(ip.blobs()[1]->cpu_diff()[s], ip2.blobs()[1]->cpu_diff()[s]); } for (int s = 0; s < prelu.blobs()[0]->count(); ++s) { EXPECT_EQ(prelu.blobs()[0]->cpu_diff()[s], prelu2.blobs()[0]->cpu_diff()[s]); } }
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; } }