//---------------------------------------------------------------------------- // Subtraction of an extended interval 'B' from a real value 'a'. //---------------------------------------------------------------------------- xinterval operator- ( const real& a, const xinterval& B ) { xinterval D; switch (B.kind) { case Finite : D.kind = Finite; // D = [D.inf,D.sup] D.inf = subd(a,B.sup); //------------------ D.sup = subu(a,B.inf); break; case PlusInfty : D.kind = MinusInfty; // D = [inf,+oo] D.sup = subu(a,B.inf); //-------------- break; case MinusInfty : D.kind = PlusInfty; // D = [-oo,sup] D.inf = subd(a,B.sup); //-------------- break; case Double : D.kind = Double; // D = [-oo,D.sup] v [D.inf,+oo] D.inf = subd(a,B.sup); //------------------------------ D.sup = subu(a,B.inf); if (D.inf < D.sup) D.inf = D.sup; break; case Empty : D.kind = Empty; // D = [/] D.inf = subd(a,B.sup); //-------- break; } // switch return D; }
int main(int argc, char** argv) { if (argc != 4) { printUsage(argv[0]); return 1; } std::vector<float> verts; std::vector<int> nvertsPerFace; std::vector<int> faceverts; if (!loadOBJ(argv[1], verts, nvertsPerFace, faceverts)) { printf("could not load %s\n", argv[1]); return 1; } saveObj(argv[2]); for (int i = 0; i < 1; i++) { Subd subd(verts.size()/3, &verts[0], nvertsPerFace.size(), &nvertsPerFace[0], &faceverts[0]); // timer t; // for (int i = 0; i < 1; i++) { // subd.subdivide(2); // } // t.stop(); // saveObj(argv[2], &subd, /*limit=*/ 1); int numsamples = atoi(argv[3]); double du = 1.0 / (numsamples-1); double dv = du; for (int f = 0; f < subd.nfaces(); f++) { double u = 0.0; for (int i = 0; i < numsamples; u += du, i++) { double v = 0.0; for (int j = 0; j < numsamples; v += dv, j++) { double p[3], dpdu[3], dpdv[3]; subd.eval(f, u, v, p, dpdu, dpdv); addLine(p, dpdu); addLine(p, dpdv); } } } } return 0; }
//-***************************************************************************** IObjectDrw::IObjectDrw( IObject &iObj, bool iResetIfNoChildren ) : m_object( iObj ) , m_minTime( ( chrono_t )FLT_MAX ) , m_maxTime( ( chrono_t )-FLT_MAX ) { // If not valid, just bail. if ( !m_object ) { return; } // IObject has no explicit time sampling, but its children may. size_t numChildren = m_object.getNumChildren(); for ( size_t i = 0; i < numChildren; ++i ) { const ObjectHeader &ohead = m_object.getChildHeader( i ); // Decide what to make. DrawablePtr dptr; if ( IPolyMesh::matches( ohead ) ) { IPolyMesh pmesh( m_object, ohead.getName() ); if ( pmesh ) { dptr.reset( new IPolyMeshDrw( pmesh ) ); } } else if ( IPoints::matches( ohead ) ) { IPoints points( m_object, ohead.getName() ); if ( points ) { dptr.reset( new IPointsDrw( points ) ); } } else if ( ICurves::matches( ohead ) ) { ICurves curves( m_object, ohead.getName() ); if ( curves ) { dptr.reset( new ICurvesDrw( curves ) ); } } else if ( INuPatch::matches( ohead ) ) { INuPatch nuPatch( m_object, ohead.getName() ); if ( nuPatch ) { dptr.reset( new INuPatchDrw( nuPatch ) ); } } else if ( IXform::matches( ohead ) ) { IXform xform( m_object, ohead.getName() ); if ( xform ) { dptr.reset( new IXformDrw( xform ) ); } } else if ( ISubD::matches( ohead ) ) { ISubD subd( m_object, ohead.getName() ); if ( subd ) { dptr.reset( new ISubDDrw( subd ) ); } } else { IObject object( m_object, ohead.getName() ); if ( object ) { dptr.reset( new IObjectDrw( object, true ) ); } } if ( dptr && dptr->valid() ) { m_children.push_back( dptr ); m_minTime = std::min( m_minTime, dptr->getMinTime() ); m_maxTime = std::max( m_maxTime, dptr->getMaxTime() ); } } // Make the bounds empty to start m_bounds.makeEmpty(); // If we have no children, just leave. if ( m_children.size() == 0 && iResetIfNoChildren ) { m_object.reset(); } }