// // $Id: Wedge.cpp,v 1.9 2000/07/19 16:33:02 hobbs Exp $ // // File: Wedge.cpp // Purpose: // Created: 24-NOV-1997 Emanuela Barberis // // $Revision: 1.9 $ // // // Include files #include #include #include #include using namespace std; using namespace dgs; bool Wedge::resize(const double dhalfwidth1, const double dhalfwidth2, const double dhalfheight) // // Purpose: Resize the wedge. Does not affect global positions of // dependent geometry structures. // // { _halfwidth1 += dhalfwidth1; _halfwidth2 += dhalfwidth2; _halfheight += dhalfheight; return true; } SpacePoint Wedge::local_to_global(const CartesianCoordinate& lpt) const // // Purpose: // States: // { return GeometryElement::local_to_global(lpt); } MatrixD Wedge::local_to_global(const CartesianMatrix& theMatrix) const // // Purpose: // States: // { return GeometryElement::local_to_global(theMatrix); } CartesianCoordinate Wedge::global_to_local(const SpacePoint& gpt) const // // Purpose: Convert a global point to its local point representation // States: // { CartesianCoordinate undone = get_position().invert(gpt); double x = undone.x(); double y = undone.y(); if( undone.z() != 0.0 ) { std::cerr << " Wedge::global_to_local. Local coordinate" << " has non-zero z-component" << std::endl; return CartesianCoordinate(0.0,0.0,0.0); } // Check y if(y<-_halfheight || y>_halfheight) { std::cerr << " Wedge::global_to_local. y = " << y << "outside range of [" << -_halfheight << "," << _halfheight << "]" << endl; return CartesianCoordinate(0.0,0.0,0.0); } double xmin=-(_halfwidth1+((_halfwidth2-_halfwidth1)/(2*_halfheight)) *(y+_halfheight)); double xmax=-xmin; // Check x if(xxmax) { std::cerr << " Wedge::global_to_local. x = " << x << "outside range of [" << xmin << "," << xmax << "]" << endl; return CartesianCoordinate(0.0,0.0,0.0); } // OK return CartesianCoordinate(x,y,0.0); } CartesianCoordinate Wedge::xform_to_local(const GeometryXform& xf) const // // Purpose: Convert a (local)transform to local coordinates. Lose the // rotation information. // { return CartesianCoordinate(xf[0],xf[1],0.0); } GeometryXform Wedge::local_to_xform(const CartesianCoordinate& lpt) const // // Purpose: Create a transformation describing a point on my surface // { return GeometryXform(lpt.x(),lpt.y(),lpt.z(),0.0,0.0,0.0); } bool Wedge::position_child_at(const CartesianCoordinate& lpt, GeometryElement& kid) // // Purpose: // States: // { GeometryXform gxf = local_to_xform(lpt); gxf = get_position().apply(gxf); kid.set_position(gxf); return true; } const std::list Wedge::get_children() // // Purpose: Complete the GeometryElement interface. Never have children on a // general wedge // { std::list empty_list; return empty_list; } std::ostream& dgs::operator <<(std::ostream& os, const Wedge& me) // // Purpose: Dump the definition of the wedge // States: // { os << "Wedge (inner half width, outer half width, half height)=(" << me._halfwidth1 << "," << me._halfwidth2 << "," << me._halfheight << ") at " << me.get_position(); return os; }