/*
Copyright 2010, 2010 STARWest
See the file STARWest.txt for details about the STARWest research group
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
// heliostat.cpp*
#include "shape.h"
#include "paramset.h"
#include "dynload.h"
// Heliostat Declarations
class Heliostat: public Shape {
public:
// Heliostat Public Methods
Heliostat(const Transform &o2w, bool ro, float rad,
float zmin, float zmax, float phiMax);
BBox ObjectBound() const;
bool CanIntersect() const { return false; }
void Refine(vector > &refined) const;
friend class Sphere;
private:
// Heliostat Private Data
float radius;
float phiMax;
float zmin, zmax;
float thetaMin, thetaMax;
};
// Heliostat Method Definitions
Heliostat::Heliostat(const Transform &o2w, bool ro, float rad,
float z0, float z1, float pm)
: Shape(o2w, ro) {
radius = rad;
zmin = Clamp(min(z0, z1), -radius, radius);
zmax = Clamp(max(z0, z1), -radius, radius);
thetaMin = acosf(Clamp(zmin/radius, -1.f, 1.f));
thetaMax = acosf(Clamp(zmax/radius, -1.f, 1.f));
phiMax = Radians(Clamp(pm, 0.0f, 360.0f));
}
BBox Heliostat::ObjectBound() const {
return BBox(Point(-radius, -radius, zmin),
Point(radius, radius, zmax));
}
void Heliostat::Refine(vector > &refined) const {
ParamSet paramset;
float radius1,radius2,height2;
radius1=radius/2;
radius2=radius;
height2=1;
paramset.AddFloat("radius", &radius1, 1);
refined.push_back(MakeShape("sphere",ObjectToWorld, reverseOrientation, paramset));
paramset.AddFloat("radius", &radius2, 1);
paramset.AddFloat("height", &height2, 1);
refined.push_back(MakeShape("disk",ObjectToWorld, reverseOrientation, paramset));
}
extern "C" DLLEXPORT
Shape *CreateShape(const Transform &o2w,
bool reverseOrientation,
const ParamSet ¶ms) {
float radius = params.FindOneFloat("radius", 1.f);
float zmin = params.FindOneFloat("zmin", -radius);
float zmax = params.FindOneFloat("zmax", radius);
float phimax = params.FindOneFloat("phimax", 360.f);
return new Heliostat(o2w, reverseOrientation, radius,
zmin, zmax, phimax);
}