本文整理汇总了C++中Option::is_defined方法的典型用法代码示例。如果您正苦于以下问题:C++ Option::is_defined方法的具体用法?C++ Option::is_defined怎么用?C++ Option::is_defined使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Option
的用法示例。
在下文中一共展示了Option::is_defined方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: obstructs
bool Scene::obstructs(const Point& beginning, const Point& end) const {
rt::vector vector = end - beginning;
Ray ray = Ray(beginning, vector, 0);
for (std::vector<Object*>::const_iterator it = objects.begin(); it != objects.end(); ++it) {
Option<double> distance = (*it)->get_distance_of_incidence_point_of(ray);
if (distance.is_defined()) {
if (distance.get_value() > EPSILON && std::abs(distance.get_value() - vector.norm()) > EPSILON) {
return true;
}
}
}
return false;
}
示例2: determine_light_of
Light Scene::determine_light_of(const Ray& ray) const {
const Option< std::pair<Object*, Point> > result = this->get_incidence_point_of(ray);
if (! result.is_defined()) {
return Light(background);
}
std::pair<Object*, Point> pair = result.get_value();
Object *object = pair.first;
Point point = pair.second;
Texture texture = object->get_texture();
unsigned int propagations_left = ray.get_propagations_left();
//if (propagations_left == 0) {
//}
//std::vector< std::pair<Ray,double> > rays;
//Ray reflection_ray = object.get_reflected_vector(...);
//rt::color reflection_color = this->determine_color(reflection_ray);
return (texture.get_color() ^ this->determine_light_from_sources_at(point, object->get_normal_vector_at(point)));
}
示例3:
const Option< std::pair<Object*, Point> > Scene::get_incidence_point_of(const Ray& ray) const {
double minimal_distance = std::numeric_limits<double>::infinity();
Object *closest_intersected_object = 0;
for (std::vector<Object*>::const_iterator it = objects.begin(); it != objects.end(); ++it) {
Option<double> distance = (*it)->get_distance_of_incidence_point_of(ray);
if (distance.is_defined()) {
if (distance.get_value() < minimal_distance && distance.get_value() > EPSILON) {
minimal_distance = distance.get_value();
closest_intersected_object = *it;
}
}
}
if (closest_intersected_object == 0) {
return Option< std::pair<Object*, Point> >(false, std::pair<Object*, Point>());
}
//std::cout << ray.get_origin() + (1/(ray.get_direction() | rt::vector(1,0,0))) * ray.get_direction() << " " << minimal_distance << "\n";
return Option< std::pair<Object*, Point> >( std::pair<Object*, Point>(closest_intersected_object, ray.get_origin() + minimal_distance * ray.get_direction()));
}